File tree Expand file tree Collapse file tree 6 files changed +68
-15
lines changed Expand file tree Collapse file tree 6 files changed +68
-15
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ apiVersion: v2
22name : standard-app
33description : A Helm chart library by Cloudkite
44type : application
5- version : 1.0 .0
5+ version : 1.1 .0
66maintainters :
7788 name : cloudkite
Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ labels:
1212 label1 : somevalue
1313 label2 : anothervalue
1414
15+ # only aks is supported at the moment, you can add other options to _spot_node_selection.tpl
16+ preferSpot : aks
17+
1518ingress : # NOTE: >0.8.0 DEPRECATES this, USE .Values.ingresses
1619 annotations :
1720 cert-manager.io/cluster-issuer : letsencrypt-prod
Original file line number Diff line number Diff line change 1+ { {- define " standard-app.spotNodeSelection.nodeAffinity" -} }
2+ { {- if eq .Values.preferSpot " aks" } }
3+ nodeAffinity:
4+ preferredDuringSchedulingIgnoredDuringExecution:
5+ - weight: 60
6+ preference:
7+ matchExpressions:
8+ - key: 'kubernetes.azure.com/scalesetpriority'
9+ operator: In
10+ values:
11+ - 'spot'
12+ - weight: 10
13+ preference:
14+ matchExpressions:
15+ - key: 'kubernetes/nodetype'
16+ operator: In
17+ values:
18+ - 'regular'
19+ { {- end -} }
20+ { {- end -} }
21+
22+ { {- define " standard-app.spotNodeSelection.toleration" -} }
23+ { {- if eq .Values.preferSpot " aks" } }
24+ - key: kubernetes.azure.com/scalesetpriority
25+ operator: Equal
26+ value: spot
27+ effect: NoSchedule
28+ { {- end -} }
29+ { {- end -} }
Original file line number Diff line number Diff line change 44 " Values" $.Values
55 " Release" $.Release
66 " labels" (default (dict) $.Values.labels)
7- - }}
7+ }}
88apiVersion : batch/v1
99kind : CronJob
1010metadata :
@@ -19,18 +19,25 @@ spec:
1919 name : {{ $cronjobName }}
2020 {{- include "standard-app.labels" $cronjobValues | nindent 6 }}
2121 spec :
22- backoffLimit : {{ $cronjobConfig.backoffLImit | default "0" }}
22+ backoffLimit : {{ $cronjobConfig.backoffLimit | default "0" }}
2323 template :
2424 metadata :
2525 {{- include "standard-app.labels" $cronjobValues | nindent 10 }}
2626 spec :
27- {{- if $cronjobConfig.affinity }}
27+ {{- if or $cronjobConfig.affinity $.Values.preferSpot }}
2828 affinity :
29- {{- toYaml $cronjobConfig.affinity | nindent 12 }}
29+ {{- $jobAffinity := default dict $cronjobConfig.affinity }}
30+ {{- $spotAffinity := fromYaml (include "standard-app.spotNodeSelection.nodeAffinity" $ | trim) }}
31+ {{- toYaml (merge $spotAffinity $jobAffinity) | nindent 10 }}
3032 {{- end }}
31- {{- if $cronjobConfig.tolerations }}
33+ {{- if or $cronjobConfig.tolerations $.Values.preferSpot }}
3234 tolerations :
33- {{- toYaml $cronjobConfig.tolerations | nindent 12 }}
35+ {{- if $cronjobConfig.tolerations }}
36+ {{- toYaml $cronjobConfig.tolerations | nindent 12 }}
37+ {{- end }}
38+ {{- if $.Values.preferSpot }}
39+ {{- include "standard-app.spotNodeSelection.toleration" $ | trim | nindent 12 }}
40+ {{- end }}
3441 {{- end }}
3542 {{- if $cronjobConfig.nodeSelector }}
3643 nodeSelector :
Original file line number Diff line number Diff line change @@ -36,13 +36,20 @@ spec:
3636 secret.reloader.stakater.com/reload : {{ $.Release.Name }}
3737 {{- end }}
3838 spec :
39- {{- if $appConfig.affinity }}
39+ {{- if or $appConfig.affinity $.Values.preferSpot }}
4040 affinity :
41- {{- toYaml $appConfig.affinity | nindent 8 }}
41+ {{- $jobAffinity := default dict $appConfig.affinity }}
42+ {{- $spotAffinity := fromYaml (include "standard-app.spotNodeSelection.nodeAffinity" $ | trim) }}
43+ {{- toYaml (merge $spotAffinity $jobAffinity) | nindent 8 }}
4244 {{- end }}
43- {{- if $appConfig.tolerations }}
45+ {{- if or $appConfig.tolerations $.Values.preferSpot }}
4446 tolerations :
45- {{- toYaml $appConfig.tolerations | nindent 8 }}
47+ {{- if $appConfig.tolerations }}
48+ {{- toYaml $appConfig.tolerations | nindent 8 }}
49+ {{- end }}
50+ {{- if $.Values.preferSpot }}
51+ {{- include "standard-app.spotNodeSelection.toleration" $ | trim | nindent 8 }}
52+ {{- end }}
4653 {{- end }}
4754 {{- if $appConfig.nodeSelector }}
4855 nodeSelector :
Original file line number Diff line number Diff line change @@ -19,13 +19,20 @@ spec:
1919 metadata :
2020 {{- include "standard-app.labels" $jobValues | nindent 6 }}
2121 spec :
22- {{- if $jobConfig.affinity }}
22+ {{- if or $jobConfig.affinity $.Values.preferSpot }}
2323 affinity :
24- {{- toYaml $jobConfig.affinity | nindent 8 }}
24+ {{- $jobAffinity := default dict $jobConfig.affinity }}
25+ {{- $spotAffinity := fromYaml (include "standard-app.spotNodeSelection.nodeAffinity" $ | trim) }}
26+ {{- toYaml (merge $spotAffinity $jobAffinity) | nindent 8 }}
2527 {{- end }}
26- {{- if $jobConfig.tolerations }}
28+ {{- if or $jobConfig.tolerations $.Values.preferSpot }}
2729 tolerations :
28- {{- toYaml $jobConfig.tolerations | nindent 8 }}
30+ {{- if $jobConfig.tolerations }}
31+ {{- toYaml $jobConfig.tolerations | nindent 8 }}
32+ {{- end }}
33+ {{- if $.Values.preferSpot }}
34+ {{- include "standard-app.spotNodeSelection.toleration" $ | trim | nindent 8 }}
35+ {{- end }}
2936 {{- end }}
3037 {{- if $jobConfig.nodeSelector }}
3138 nodeSelector :
You can’t perform that action at this time.
0 commit comments