Skip to content

Commit 3c73c71

Browse files
authored
Merge branch 'main' into issue-176-include-image-pull-secrets
2 parents c2f8669 + 61603cb commit 3c73c71

32 files changed

+967
-643
lines changed

.github/workflows/ci.yml

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
jobs:
10-
1110
build:
1211
runs-on: ubuntu-latest
1312
steps:
14-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v3
1514

16-
# GO tests
17-
- name: Set up Go
18-
uses: actions/setup-go@v4
19-
with:
20-
go-version: '1.21'
21-
cache: false
15+
# GO tests
16+
- name: Set up Go
17+
uses: actions/setup-go@v4
18+
with:
19+
go-version: "1.21"
20+
cache: false
2221

23-
- name: Fmt
24-
run: |
22+
- name: Fmt
23+
run: |
2524
# Run gofmt in "diff" mode to check for unformatted code
2625
UNFORMATTED_FILES=$(gofmt -l .)
2726
# Check if any files are unformatted
@@ -33,23 +32,23 @@ jobs:
3332
else
3433
echo "All Go files are properly formatted."
3534
fi
36-
- name: Vet
37-
run: go vet ./...
35+
- name: Vet
36+
run: go vet ./...
3837

39-
- name: Test
40-
run: go test ./...
38+
- name: Test
39+
run: go test ./...
4140

42-
- name: golangci-lint
43-
uses: golangci/golangci-lint-action@v3
44-
with:
45-
version: v1.54
46-
# Generate example charts
47-
- name: Generate example charts
48-
run: |
41+
- name: golangci-lint
42+
uses: golangci/golangci-lint-action@v3
43+
with:
44+
version: v1.54
45+
# Generate example charts
46+
- name: Generate example charts
47+
run: |
4948
cat test_data/sample-app.yaml | go run ./cmd/helmify examples/app
5049
cat test_data/k8s-operator-kustomize.output | go run ./cmd/helmify examples/operator
51-
- name: Check that chart examples were commited
52-
run: |
50+
- name: Check that chart examples were commited
51+
run: |
5352
if [[ -n "$(git status --porcelain)" ]]; then
5453
# Capture the list of uncommitted files
5554
UNCOMMITTED_FILES=$(git status --porcelain)
@@ -61,36 +60,36 @@ jobs:
6160
else
6261
echo "Chart examples generation check passed. No uncommitted changes."
6362
fi
64-
# Dry-run generated charts in cluster
65-
- name: Install k8s cluster
66-
uses: helm/kind-action@v1.4.0
67-
- name: Install certs
68-
run: kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.1.1/cert-manager.yaml
63+
# Dry-run generated charts in cluster
64+
- name: Install k8s cluster
65+
uses: helm/kind-action@v1.13.0
66+
- name: Install certs
67+
run: kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.1.1/cert-manager.yaml
6968

70-
- name: Generate operator ci chart
71-
run: cat test_data/k8s-operator-ci.yaml | go run ./cmd/helmify examples/operator-ci
72-
- name: Fill operator ci secrets
73-
run: sed -i 's/""/"abc"/' ./examples/operator-ci/values.yaml
74-
- name: Dry-run operator in k8s cluster
75-
run: helm template ./examples/operator-ci -n operator-ns --create-namespace | kubectl apply --dry-run=server -f -
69+
- name: Generate operator ci chart
70+
run: cat test_data/k8s-operator-ci.yaml | go run ./cmd/helmify examples/operator-ci
71+
- name: Fill operator ci secrets
72+
run: sed -i 's/""/"abc"/' ./examples/operator-ci/values.yaml
73+
- name: Dry-run operator in k8s cluster
74+
run: helm template ./examples/operator-ci -n operator-ns --create-namespace | kubectl apply --dry-run=server -f -
7675

77-
- name: Generate app chart
78-
run: cat test_data/sample-app.yaml | go run ./cmd/helmify examples/app
79-
- name: Fill app secrets
80-
run: sed -i 's/""/"abc"/' ./examples/app/values.yaml
81-
- name: Dry-run app in k8s cluster
82-
run: helm template ./examples/app -n app-ns --create-namespace | kubectl apply --dry-run=server -f -
76+
- name: Generate app chart
77+
run: cat test_data/sample-app.yaml | go run ./cmd/helmify examples/app
78+
- name: Fill app secrets
79+
run: sed -i 's/""/"abc"/' ./examples/app/values.yaml
80+
- name: Dry-run app in k8s cluster
81+
run: helm template ./examples/app -n app-ns --create-namespace | kubectl apply --dry-run=server -f -
8382

84-
# Validate charts with Kubeconform
85-
- name: Install Kubeconform
86-
run: go install github.com/yannh/kubeconform/cmd/[email protected]
83+
# Validate charts with Kubeconform
84+
- name: Install Kubeconform
85+
run: go install github.com/yannh/kubeconform/cmd/[email protected]
8786

88-
- name: Validate app
89-
run: helm template ./examples/app -n app-ns --create-namespace | kubeconform -schema-location 'https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/v3/apis__apiextensions.k8s.io__v1_openapi.json' -strict
87+
- name: Validate app
88+
run: helm template ./examples/app -n app-ns --create-namespace | kubeconform -schema-location 'https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/v3/apis__apiextensions.k8s.io__v1_openapi.json' -strict
9089

91-
- name: Generate operator example chart
92-
run: cat test_data/k8s-operator-kustomize.output | go run ./cmd/helmify examples/operator
93-
- name: Fill operator example secrets
94-
run: sed -i 's/""/"abc"/' ./examples/operator/values.yaml
95-
- name: Validate example operator
96-
run: helm template ./examples/operator -n operator-ns --create-namespace | kubeconform -schema-location 'https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/v3/apis__apiextensions.k8s.io__v1_openapi.json' -strict
90+
- name: Generate operator example chart
91+
run: cat test_data/k8s-operator-kustomize.output | go run ./cmd/helmify examples/operator
92+
- name: Fill operator example secrets
93+
run: sed -i 's/""/"abc"/' ./examples/operator/values.yaml
94+
- name: Validate example operator
95+
run: helm template ./examples/operator -n operator-ns --create-namespace | kubeconform -schema-location 'https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/v3/apis__apiextensions.k8s.io__v1_openapi.json' -strict

examples/app/templates/_helpers.tpl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,12 @@ app.kubernetes.io/instance: {{ .Release.Name }}
5454
Create the name of the service account to use
5555
*/}}
5656
{{- define "app.serviceAccountName" -}}
57-
{{- if .Values.serviceAccount.create }}
58-
{{- default (include "app.fullname" .) .Values.serviceAccount.name }}
57+
{{- $default := (include "app.fullname" .) }}
58+
{{- with .Values.serviceAccount }}
59+
{{- if .create }}
60+
{{- default $default .name }}
5961
{{- else }}
60-
{{- default "default" .Values.serviceAccount.name }}
62+
{{- default "default" .name }}
63+
{{- end }}
6164
{{- end }}
6265
{{- end }}

examples/app/templates/batch-job.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ spec:
2121
| default .Chart.AppVersion }}
2222
name: pi
2323
resources: {}
24+
nodeSelector: {{- toYaml .Values.batchJob.nodeSelector | nindent 8 }}
2425
restartPolicy: Never
26+
serviceAccountName: {{ include "app.serviceAccountName" . }}
27+
tolerations: {{- toYaml .Values.batchJob.tolerations | nindent 8 }}
28+
topologySpreadConstraints: {{- toYaml .Values.batchJob.topologySpreadConstraints
29+
| nindent 8 }}

examples/app/templates/cron-job.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,10 @@ spec:
2222
imagePullPolicy: {{ .Values.cronJob.hello.imagePullPolicy }}
2323
name: hello
2424
resources: {}
25+
nodeSelector: {{- toYaml .Values.cronJob.nodeSelector | nindent 12 }}
2526
restartPolicy: OnFailure
27+
serviceAccountName: {{ include "app.serviceAccountName" . }}
28+
tolerations: {{- toYaml .Values.cronJob.tolerations | nindent 12 }}
29+
topologySpreadConstraints: {{- toYaml .Values.cronJob.topologySpreadConstraints
30+
| nindent 12 }}
2631
schedule: {{ .Values.cronJob.schedule | quote }}

examples/app/templates/daemonset.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ spec:
3232
- mountPath: /var/lib/docker/containers
3333
name: varlibdockercontainers
3434
readOnly: true
35+
nodeSelector: {{- toYaml .Values.fluentdElasticsearch.nodeSelector | nindent 8 }}
36+
serviceAccountName: {{ include "app.serviceAccountName" . }}
3537
terminationGracePeriodSeconds: 30
36-
tolerations:
37-
- effect: NoSchedule
38-
key: node-role.kubernetes.io/master
39-
operator: Exists
38+
tolerations: {{- toYaml .Values.fluentdElasticsearch.tolerations | nindent 8 }}
39+
topologySpreadConstraints: {{- toYaml .Values.fluentdElasticsearch.topologySpreadConstraints
40+
| nindent 8 }}
4041
volumes:
4142
- hostPath:
4243
path: /var/log

examples/app/templates/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ spec:
9696
resources: {}
9797
nodeSelector: {{- toYaml .Values.myapp.nodeSelector | nindent 8 }}
9898
securityContext: {{- toYaml .Values.myapp.podSecurityContext | nindent 8 }}
99+
serviceAccountName: {{ include "app.serviceAccountName" . }}
99100
terminationGracePeriodSeconds: 10
101+
tolerations: {{- toYaml .Values.myapp.tolerations | nindent 8 }}
102+
topologySpreadConstraints: {{- toYaml .Values.myapp.topologySpreadConstraints | nindent
103+
8 }}
100104
volumes:
101105
- configMap:
102106
name: {{ include "app.fullname" . }}-my-config
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "app.fullname" . }}-myapp-ipfamily-service
5+
labels:
6+
app: myapp
7+
{{- include "app.labels" . | nindent 4 }}
8+
spec:
9+
type: {{ .Values.myappIpfamilyService.type }}
10+
selector:
11+
app: myapp
12+
{{- include "app.selectorLabels" . | nindent 4 }}
13+
{{- if .Values.myappIpfamilyService.ipFamilyPolicy }}
14+
ipFamilyPolicy: {{ .Values.myappIpfamilyService.ipFamilyPolicy }}
15+
{{- end }}
16+
{{- if .Values.myappIpfamilyService.ipFamilies }}
17+
ipFamilies:
18+
{{- .Values.myappIpfamilyService.ipFamilies | toYaml | nindent 2 }}
19+
{{- end }}
20+
ports:
21+
{{- .Values.myappIpfamilyService.ports | toYaml | nindent 2 }}

examples/app/templates/statefulset.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ spec:
2929
volumeMounts:
3030
- mountPath: /usr/share/nginx/html
3131
name: www
32+
nodeSelector: {{- toYaml .Values.web.nodeSelector | nindent 8 }}
33+
serviceAccountName: {{ include "app.serviceAccountName" . }}
34+
tolerations: {{- toYaml .Values.web.tolerations | nindent 8 }}
35+
topologySpreadConstraints: {{- toYaml .Values.web.topologySpreadConstraints |
36+
nindent 8 }}
3237
updateStrategy: {}
3338
volumeClaimTemplates:
3439
- metadata:

examples/app/values.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
batchJob:
22
backoffLimit: 4
3+
nodeSelector: {}
34
pi:
45
image:
56
repository: perl
67
tag: 5.34.0
8+
tolerations: []
9+
topologySpreadConstraints: []
710
cronJob:
811
hello:
912
image:
1013
repository: busybox
1114
tag: "1.28"
1215
imagePullPolicy: IfNotPresent
16+
nodeSelector: {}
1317
schedule: '* * * * *'
18+
tolerations: []
19+
topologySpreadConstraints: []
1420
fluentdElasticsearch:
1521
fluentdElasticsearch:
1622
image:
@@ -22,6 +28,12 @@ fluentdElasticsearch:
2228
requests:
2329
cpu: 100m
2430
memory: 200Mi
31+
nodeSelector: {}
32+
tolerations:
33+
- effect: NoSchedule
34+
key: node-role.kubernetes.io/master
35+
operator: Exists
36+
topologySpreadConstraints: []
2537
kubernetesClusterDomain: cluster.local
2638
myConfig:
2739
dummyconfigmapkey: dummyconfigmapvalue
@@ -89,6 +101,17 @@ myapp:
89101
tag: v0.8.0
90102
replicas: 3
91103
revisionHistoryLimit: 5
104+
tolerations: []
105+
topologySpreadConstraints: []
106+
myappIpfamilyService:
107+
ipFamilies:
108+
- IPv4
109+
ipFamilyPolicy: SingleStack
110+
ports:
111+
- name: https
112+
port: 8443
113+
targetPort: https
114+
type: ClusterIP
92115
myappLbService:
93116
loadBalancerSourceRanges:
94117
- 10.0.0.0/8
@@ -121,7 +144,10 @@ web:
121144
image:
122145
repository: registry.k8s.io/nginx-slim
123146
tag: "0.8"
147+
nodeSelector: {}
124148
replicas: 2
149+
tolerations: []
150+
topologySpreadConstraints: []
125151
volumeClaims:
126152
www:
127153
requests:

examples/operator/templates/deployment.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,11 @@ spec:
9696
nodeSelector: {{- toYaml .Values.controllerManager.nodeSelector | nindent 8 }}
9797
securityContext: {{- toYaml .Values.controllerManager.podSecurityContext | nindent
9898
8 }}
99-
serviceAccountName: {{ include "operator.fullname" . }}-controller-manager
99+
serviceAccountName: {{ include "operator.serviceAccountName" . }}
100100
terminationGracePeriodSeconds: 10
101-
topologySpreadConstraints:
102-
- matchLabelKeys:
103-
- app
104-
- pod-template-hash
105-
maxSkew: 1
106-
topologyKey: kubernetes.io/hostname
107-
whenUnsatisfiable: DoNotSchedule
101+
tolerations: {{- toYaml .Values.controllerManager.tolerations | nindent 8 }}
102+
topologySpreadConstraints: {{- toYaml .Values.controllerManager.topologySpreadConstraints
103+
| nindent 8 }}
108104
volumes:
109105
- configMap:
110106
name: {{ include "operator.fullname" . }}-manager-config

0 commit comments

Comments
 (0)