Skip to content

Commit b447819

Browse files
Merge pull request #60 from cloudkite-io/add-tolerations
Add tolerations, nodeSelector, and affinity to workloads
2 parents 34f331e + 34ea1a9 commit b447819

File tree

5 files changed

+80
-2
lines changed

5 files changed

+80
-2
lines changed

standard-app/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: standard-app
33
description: A Helm chart library by Cloudkite
44
type: application
5-
version: 0.9.5
5+
version: 0.9.6
66
maintainters:
77
88
name: cloudkite

standard-app/example.values.yaml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,21 @@ apps:
318318
capabilities:
319319
drop:
320320
- ALL
321+
nodeSelector:
322+
node-label: "my-node-pool" # Optional, if not specified it defaults to the default node selector for the cluster
323+
tolerations:
324+
- key: purpose
325+
operator: Equal
326+
value: run-example-app-1a-node
327+
effect: NoSchedule
328+
affinity:
329+
nodeAffinity:
330+
requiredDuringSchedulingIgnoredDuringExecution:
331+
nodeSelectorTerms:
332+
- matchExpressions:
333+
- key: cloud.google.com/gke-preemptible
334+
operator: DoesNotExist
335+
321336

322337
example-app-2:
323338
serviceAccount: cloudkite
@@ -500,6 +515,20 @@ jobs:
500515
items:
501516
- key: env
502517
path: .env
518+
nodeSelector:
519+
node-label: "my-node-pool" # Optional, if not specified it defaults to the default node selector for the cluster
520+
tolerations:
521+
- key: purpose
522+
operator: Equal
523+
value: run-example-app-1a-node
524+
effect: NoSchedule
525+
affinity:
526+
nodeAffinity:
527+
requiredDuringSchedulingIgnoredDuringExecution:
528+
nodeSelectorTerms:
529+
- matchExpressions:
530+
- key: cloud.google.com/gke-preemptible
531+
operator: DoesNotExist
503532

504533
cronjobs:
505534
cronjobexample-1:
@@ -538,7 +567,20 @@ cronjobs:
538567
DATE=$(date +%d_%m)
539568
#'{{ .Files.Get "scripts/test_script.sh" | nindent 4 }}' we are currently working on making configMap script data workable from a repo that's not standard library, for now you can use it like this.
540569

541-
570+
nodeSelector:
571+
node-label: "my-node-pool" # Optional, if not specified it defaults to the default node selector for the cluster
572+
tolerations:
573+
- key: purpose
574+
operator: Equal
575+
value: run-example-app-1a-node
576+
effect: NoSchedule
577+
affinity:
578+
nodeAffinity:
579+
requiredDuringSchedulingIgnoredDuringExecution:
580+
nodeSelectorTerms:
581+
- matchExpressions:
582+
- key: cloud.google.com/gke-preemptible
583+
operator: DoesNotExist
542584
initContainers:
543585
exampleinitcontainer-1:
544586
image: google/cloud-sdk

standard-app/templates/workloads/cronjob.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ spec:
4949
operator: Equal
5050
value: "true"
5151
{{- end }}
52+
{{- if $cronjobConfig.affinity }}
53+
affinity:
54+
{{- toYaml $cronjobConfig.affinity | nindent 12 }}
55+
{{- end }}
56+
{{- if $cronjobConfig.tolerations }}
57+
tolerations:
58+
{{- toYaml $cronjobConfig.tolerations | nindent 12 }}
59+
{{- end }}
60+
{{- if $cronjobConfig.nodeSelector }}
61+
nodeSelector:
62+
{{- toYaml $cronjobConfig.nodeSelector | nindent 12 }}
63+
{{- end }}
5264
{{- if $cronjobConfig.serviceAccount }}
5365
serviceAccountName: {{ $cronjobConfig.serviceAccount }}
5466
{{- end }}

standard-app/templates/workloads/deployment.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ spec:
5656
operator: Equal
5757
value: "true"
5858
{{- end }}
59+
{{- if $appConfig.affinity }}
60+
affinity:
61+
{{- toYaml $appConfig.affinity | nindent 8 }}
62+
{{- end }}
63+
{{- if $appConfig.tolerations }}
64+
tolerations:
65+
{{- toYaml $appConfig.tolerations | nindent 8 }}
66+
{{- end }}
67+
{{- if $appConfig.nodeSelector }}
68+
nodeSelector:
69+
{{- toYaml $appConfig.nodeSelector | nindent 8 }}
70+
{{- end }}
5971
{{- if $appConfig.podSecurityContext }}
6072
securityContext:
6173
{{- toYaml $appConfig.podSecurityContext | nindent 8 }}

standard-app/templates/workloads/job.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ spec:
3939
operator: Equal
4040
value: "true"
4141
{{- end }}
42+
{{- if $jobConfig.affinity }}
43+
affinity:
44+
{{- toYaml $jobConfig.affinity | nindent 8 }}
45+
{{- end }}
46+
{{- if $jobConfig.tolerations }}
47+
tolerations:
48+
{{- toYaml $jobConfig.tolerations | nindent 8 }}
49+
{{- end }}
50+
{{- if $jobConfig.nodeSelector }}
51+
nodeSelector:
52+
{{- toYaml $jobConfig.nodeSelector | nindent 8 }}
53+
{{- end }}
4254
{{- if $jobConfig.serviceAccount }}
4355
serviceAccountName: {{ $jobConfig.serviceAccount }}
4456
{{- end }}

0 commit comments

Comments
 (0)