Skip to content

Commit 08ada30

Browse files
authored
misc: added support for cronjob annotations and probes (#6787)
* added support for cronjob annotations and probes * support for older charts * reconfiguring semverCompare * removed restartPolicy from cronjob-config * added support for external-secrets.io/v1 * added default values for eso * older compatibility * rectify the semverCompare * added support for jobLabels and jobAnnotations
1 parent fdcab1b commit 08ada30

File tree

7 files changed

+216
-32
lines changed

7 files changed

+216
-32
lines changed

scripts/devtron-reference-helm-charts/cronjob-chart_1-6-0/app-values.yaml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,34 @@ cronjobConfigs:
1515
suspend: false
1616
successfulJobsHistoryLimit: 3
1717
failedJobsHistoryLimit: 1
18-
restartPolicy: OnFailure
1918
timeZone: "UTC"
20-
19+
cronJobAnnotations: {}
20+
cronJobLabels: {}
21+
LivenessProbe:
22+
Path: ""
23+
command: []
24+
failureThreshold: 3
25+
httpHeaders: []
26+
initialDelaySeconds: 20
27+
periodSeconds: 10
28+
port: 8080
29+
scheme: ""
30+
successThreshold: 1
31+
tcp: false
32+
timeoutSeconds: 5
33+
ReadinessProbe:
34+
Path: ""
35+
command: []
36+
failureThreshold: 3
37+
httpHeaders: []
38+
initialDelaySeconds: 20
39+
periodSeconds: 10
40+
port: 8080
41+
scheme: ""
42+
successThreshold: 1
43+
tcp: false
44+
timeoutSeconds: 5
45+
restartPolicy: OnFailure
2146
kedaAutoscaling:
2247
envSourceContainerName: ""
2348
minReplicaCount: 1

scripts/devtron-reference-helm-charts/cronjob-chart_1-6-0/templates/_pod_template_spec.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,79 @@ containers:
150150
{{- if $.Values.containerExtraSpecs }}
151151
{{ toYaml .Values.containerExtraSpecs | indent 4 }}
152152
{{- end }}
153+
{{- if $.Values.LivenessProbe }}
154+
{{- if or $.Values.LivenessProbe.Path $.Values.LivenessProbe.command $.Values.LivenessProbe.tcp $.Values.LivenessProbe.grpc }}
155+
livenessProbe:
156+
{{- if $.Values.LivenessProbe.Path }}
157+
httpGet:
158+
path: {{ $.Values.LivenessProbe.Path }}
159+
port: {{ $.Values.LivenessProbe.port }}
160+
scheme: {{ $.Values.LivenessProbe.scheme }}
161+
{{- if $.Values.LivenessProbe.httpHeaders }}
162+
httpHeaders:
163+
{{- range $.Values.LivenessProbe.httpHeaders}}
164+
- name: {{.name}}
165+
value: {{.value}}
166+
{{- end}}
167+
{{- end }}
168+
{{- end }}
169+
{{- if $.Values.LivenessProbe.command }}
170+
exec:
171+
command:
172+
{{ toYaml .Values.LivenessProbe.command | indent 16 }}
173+
{{- end}}
174+
{{- if and $.Values.LivenessProbe.tcp }}
175+
tcpSocket:
176+
port: {{ $.Values.LivenessProbe.port }}
177+
{{- end}}
178+
initialDelaySeconds: {{ $.Values.LivenessProbe.initialDelaySeconds }}
179+
periodSeconds: {{ $.Values.LivenessProbe.periodSeconds }}
180+
successThreshold: {{ $.Values.LivenessProbe.successThreshold }}
181+
timeoutSeconds: {{ $.Values.LivenessProbe.timeoutSeconds }}
182+
failureThreshold: {{ $.Values.LivenessProbe.failureThreshold }}
183+
{{- if $.Values.LivenessProbe.grpc }}
184+
grpc:
185+
{{ toYaml .Values.LivenessProbe.grpc | indent 14 }}
186+
{{- end }}
187+
{{- end }}
188+
{{- end }}
189+
{{- if $.Values.ReadinessProbe }}
190+
{{- if or $.Values.ReadinessProbe.Path $.Values.ReadinessProbe.command $.Values.ReadinessProbe.tcp $.Values.ReadinessProbe.grpc }}
191+
readinessProbe:
192+
{{- if $.Values.ReadinessProbe.Path }}
193+
httpGet:
194+
path: {{ $.Values.ReadinessProbe.Path }}
195+
port: {{ $.Values.ReadinessProbe.port }}
196+
scheme: {{ $.Values.ReadinessProbe.scheme }}
197+
{{- if $.Values.ReadinessProbe.httpHeaders }}
198+
httpHeaders:
199+
{{- range $.Values.ReadinessProbe.httpHeaders}}
200+
- name: {{.name}}
201+
value: {{.value}}
202+
{{- end}}
203+
{{- end }}
204+
{{- end }}
205+
{{- if $.Values.ReadinessProbe.command }}
206+
exec:
207+
command:
208+
{{ toYaml .Values.ReadinessProbe.command | indent 16 }}
209+
{{- end}}
210+
{{- if and $.Values.ReadinessProbe.tcp }}
211+
tcpSocket:
212+
port: {{ $.Values.ReadinessProbe.port }}
213+
{{- end}}
214+
initialDelaySeconds: {{ $.Values.ReadinessProbe.initialDelaySeconds }}
215+
periodSeconds: {{ $.Values.ReadinessProbe.periodSeconds }}
216+
successThreshold: {{ $.Values.ReadinessProbe.successThreshold }}
217+
timeoutSeconds: {{ $.Values.ReadinessProbe.timeoutSeconds }}
218+
failureThreshold: {{ $.Values.ReadinessProbe.failureThreshold }}
219+
{{- if $.Values.ReadinessProbe.grpc }}
220+
grpc:
221+
{{ toYaml .Values.ReadinessProbe.grpc | indent 14 }}
222+
{{- end}}
223+
{{- end }}
224+
{{- end }}
225+
153226
{{- if $.Values.privileged }}
154227
securityContext:
155228
privileged: true

scripts/devtron-reference-helm-charts/cronjob-chart_1-6-0/templates/cronjob.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ metadata:
1212
chart: {{ template ".Chart.Name .chart" $ }}
1313
release: {{ $.Release.Name }}
1414
releaseVersion: {{ $.Values.releaseVersion | quote }}
15+
{{- if .Values.cronJobLabels }}
16+
{{ toYaml .Values.cronJobLabels | indent 4 }}
17+
{{- end }}
18+
{{- if .Values.cronJobAnnotations }}
19+
annotations:
20+
{{ toYaml .Values.cronJobAnnotations | indent 4 }}
21+
{{- end }}
1522
spec:
1623
{{- if $.Values.cronjobConfigs }}
1724
{{- if $.Values.cronjobConfigs.timeZone }}
@@ -26,10 +33,8 @@ spec:
2633
{{- if $.Values.cronjobConfigs.concurrencyPolicy }}
2734
concurrencyPolicy: {{ $.Values.cronjobConfigs.concurrencyPolicy }}
2835
{{- end }}
29-
{{- if semverCompare ">1.20" .Capabilities.KubeVersion.GitVersion }}
30-
{{- if $.Values.cronjobConfigs.suspend }}
31-
suspend: {{ $.Values.cronjobConfigs.suspend }}
32-
{{- end }}
36+
{{- if semverCompare ">1.20.0-0" .Capabilities.KubeVersion.Version }}
37+
suspend: {{ $.Values.cronjobConfigs.suspend | default false }}
3338
{{- end }}
3439
{{- if $.Values.cronjobConfigs.successfulJobsHistoryLimit }}
3540
successfulJobsHistoryLimit: {{ $.Values.cronjobConfigs.successfulJobsHistoryLimit }}

scripts/devtron-reference-helm-charts/cronjob-chart_1-6-0/templates/externalsecrets.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
{{if (or (eq .externalType "ESO_GoogleSecretsManager") (eq .externalType "ESO_AWSSecretsManager") (eq .externalType "ESO_HashiCorpVault") (eq .externalType "ESO_AzureSecretsManager"))}}
55
{{- if .esoSecretData.secretStore }}
66
---
7+
{{- if $.Capabilities.APIVersions.Has "external-secrets.io/v1" }}
8+
apiVersion: external-secrets.io/v1
9+
{{- else }}
710
apiVersion: external-secrets.io/v1beta1
11+
{{- end }}
812
kind: SecretStore
913
metadata:
1014
name: {{ .name}}
@@ -22,7 +26,11 @@ spec:
2226
{{- toYaml .esoSecretData.secretStore | nindent 4 }}
2327
{{- end }}
2428
---
25-
apiVersion: external-secrets.io/v1beta1
29+
{{- if $.Capabilities.APIVersions.Has "external-secrets.io/v1" }}
30+
apiVersion: external-secrets.io/v1
31+
{{- else }}
32+
apiVersion: external-secrets.io/v1beta1
33+
{{- end }}
2634
kind: ExternalSecret
2735
metadata:
2836
name: {{ .name }}

scripts/devtron-reference-helm-charts/cronjob-chart_1-6-0/templates/job.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ metadata:
99
release: {{ $.Release.Name }}
1010
releaseVersion: {{ $.Values.releaseVersion | quote }}
1111
pipelineName: {{ .Values.pipelineName }}
12+
{{- if .Values.jobLabels }}
13+
{{ toYaml .Values.jobLabels | indent 4 }}
14+
{{- end }}
15+
{{- if .Values.jobAnnotations }}
16+
annotations:
17+
{{ toYaml .Values.jobAnnotations | indent 4 }}
18+
{{- end }}
19+
1220
spec:
1321
{{- include "job-template-spec" . | indent 2 }}
1422
{{ end }}

scripts/devtron-reference-helm-charts/cronjob-chart_1-6-0/test_values.yaml

Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,40 @@ cronjobConfigs:
1818
suspend: false
1919
successfulJobsHistoryLimit: 3
2020
failedJobsHistoryLimit: 1
21-
restartPolicy: OnFailure
2221
timeZone: "UTC"
22+
cronJobAnnotations:
23+
example.com/dummy: "true"
24+
cronJobLabels:
25+
example.com/dummy: "true"
26+
jobAnnotations:
27+
example.com/dummy: "true"
28+
jobLabels:
29+
example.com/dummy: "true"
30+
LivenessProbe:
31+
Path: "/"
32+
command: []
33+
failureThreshold: 3
34+
httpHeaders: []
35+
initialDelaySeconds: 20
36+
periodSeconds: 10
37+
port: 8080
38+
scheme: ""
39+
successThreshold: 1
40+
tcp: false
41+
timeoutSeconds: 5
42+
ReadinessProbe:
43+
Path: "/"
44+
command: []
45+
failureThreshold: 3
46+
httpHeaders: []
47+
initialDelaySeconds: 20
48+
periodSeconds: 10
49+
port: 8080
50+
scheme: ""
51+
successThreshold: 1
52+
tcp: false
53+
timeoutSeconds: 5
54+
restartPolicy: Always
2355

2456
imagePullSecrets:
2557
- test1
@@ -222,25 +254,34 @@ ConfigMaps:
222254
ConfigSecrets:
223255
enabled: true
224256
secrets:
225-
- name: config-secret-1
226-
type: environment
227-
external: true
228-
externalType: ESO_AWSSecretsManager
229-
esoSecretData:
230-
secretStoreRef:
231-
kind: ClusteSecret
232-
name: test-secret
233-
aws:
234-
service: SecretsManager
235-
region: us-east-1
236-
auth:
237-
secretRef:
238-
accessKeyIDSecretRef:
239-
name: awssm-secret
240-
key: access-key
241-
secretAccessKeySecretRef:
242-
name: awssm-secret
243-
key: secret-access-key
257+
- name: config-secret-1
258+
type: environment
259+
external: true
260+
externalType: ESO_AWSSecretsManager
261+
esoSecretData:
262+
refreshInterval: "30m"
263+
264+
# Option 1: Define an inline SecretStore
265+
secretStore:
266+
aws:
267+
service: SecretsManager
268+
region: us-east-1
269+
auth:
270+
secretRef:
271+
accessKeyIDSecretRef:
272+
name: awssm-secret
273+
key: access-key
274+
secretAccessKeySecretRef:
275+
name: awssm-secret
276+
key: secret-access-key
277+
278+
# Option 2: Reference an existing SecretStore / ClusterSecretStore
279+
# (comment out if not needed)
280+
secretStoreRef:
281+
kind: ClusterSecretStore # or SecretStore
282+
name: test-secret
283+
284+
# Map individual keys from AWS Secrets Manager into K8s Secret
244285
esoData:
245286
- secretKey: prod-mysql-password
246287
key: secrets/prod-mysql-secrets
@@ -254,10 +295,10 @@ ConfigSecrets:
254295
- secretKey: prod-mysql-password
255296
key: secrets/prod-mysql-secrets
256297
property: prodPassword
257-
data:
258-
key1: key1value-1
259-
key2: key2value-1
260-
key3: key3value-1
298+
data:
299+
key1: key1value-1
300+
key2: key2value-1
301+
key3: key3value-1
261302
# - name: config-secret-1
262303
# type: environment
263304
# external: false

scripts/devtron-reference-helm-charts/cronjob-chart_1-6-0/values.yaml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,30 @@ ContainerPort:
3030
# port: 8090
3131
# servicePort: 8080
3232
# useGRPC: true
33+
LivenessProbe:
34+
Path: ""
35+
command: []
36+
failureThreshold: 3
37+
httpHeaders: []
38+
initialDelaySeconds: 20
39+
periodSeconds: 10
40+
port: 8080
41+
scheme: ""
42+
successThreshold: 1
43+
tcp: false
44+
timeoutSeconds: 5
45+
ReadinessProbe:
46+
Path: ""
47+
command: []
48+
failureThreshold: 3
49+
httpHeaders: []
50+
initialDelaySeconds: 20
51+
periodSeconds: 10
52+
port: 8080
53+
scheme: ""
54+
successThreshold: 1
55+
tcp: false
56+
timeoutSeconds: 5
3357

3458
pauseForSecondsBeforeSwitchActive: 30
3559
waitForSecondsBeforeScalingDown: 30
@@ -322,4 +346,4 @@ imagePullSecrets: []
322346
# - test1
323347
# - test2
324348

325-
persistentVolumeClaim: {}
349+
persistentVolumeClaim: {}

0 commit comments

Comments
 (0)