Skip to content

Commit 74ac365

Browse files
author
klamas
committed
add global nodeSelector, tolerations and affinity
1 parent c4bf1d4 commit 74ac365

13 files changed

+235
-85
lines changed

charts/posthog/ALL_VALUES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ The following table lists the configurable parameters of the PostHog chart and t
2222
| posthogSecretKey.existingSecret | string | `nil` | Specify that the key should be pulled from an existing secret key. By default the chart will generate a secret and create a Kubernetes Secret containing it. |
2323
| posthogSecretKey.existingSecretKey | string | `"posthog-secret"` | Specify the key within the secret from which SECRET_KEY should be taken. |
2424
| env | list | `[]` | Environment variables to inject into every PostHog deployment. |
25+
| nodeSelector | object | `{}` | Global Node labels for all deployment. |
26+
| tolerations | list | `[]` | Global Toleration labels for all deployment. |
27+
| affinity | object | `{}` | Global Affinity settings for all deployment. |
2528
| migrate.enabled | bool | `true` | Whether to install the PostHog migrate job or not. |
2629
| events.enabled | bool | `true` | Whether to install the PostHog events stack or not. |
2730
| events.replicacount | int | `1` | Count of events pods to run. This setting is ignored if `events.hpa.enabled` is set to `true`. |

charts/posthog/templates/_snippet-plugins-deployment.tpl

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,9 @@ spec:
3737
{{- end }}
3838
spec:
3939
serviceAccountName: {{ template "posthog.serviceAccountName" .root }}
40-
{{- if .params.affinity }}
41-
affinity:
42-
{{- toYaml .params.affinity | nindent 8 }}
43-
{{- end }}
44-
{{- if .params.nodeSelector }}
45-
nodeSelector:
46-
{{- toYaml .params.nodeSelector | nindent 8 }}
47-
{{- end }}
48-
{{- if .params.tolerations }}
49-
tolerations:
50-
{{- toYaml .params.tolerations | nindent 8 }}
51-
{{- end }}
40+
affinity: {{ toYaml (merge .params.affinity .root.Values.affinity) | nindent 8 }}
41+
nodeSelector: {{ toYaml (merge .params.nodeSelector .root.Values.nodeSelector) | nindent 8 }}
42+
tolerations: {{ toYaml (coalesce .params.tolerations .root.Values.tolerations) | nindent 8 }}
5243
{{- if .params.schedulerName }}
5344
schedulerName: "{{ .params.schedulerName }}"
5445
{{- end }}

charts/posthog/templates/clickhouse_instance.yaml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,9 @@ spec:
6868
podDistribution: {{ toYaml .Values.clickhouse.podDistribution | nindent 12 }}
6969
{{- end}}
7070
spec:
71-
{{- if .Values.clickhouse.affinity }}
72-
affinity: {{ toYaml .Values.clickhouse.affinity | nindent 12 }}
73-
{{- end }}
74-
{{- if .Values.clickhouse.tolerations }}
75-
tolerations: {{ toYaml .Values.clickhouse.tolerations | nindent 12 }}
76-
{{- end }}
77-
{{- if .Values.clickhouse.nodeSelector }}
78-
nodeSelector: {{ toYaml .Values.clickhouse.nodeSelector | nindent 12 }}
79-
{{- end }}
80-
71+
affinity: {{ toYaml (merge .Values.clickhouse.affinity .Values.affinity) | nindent 12 }}
72+
nodeSelector: {{ toYaml (merge .Values.clickhouse.nodeSelector .Values.nodeSelector) | nindent 12 }}
73+
tolerations: {{ toYaml (coalesce .Values.clickhouse.tolerations .Values.tolerations) | nindent 12 }}
8174
{{- if .Values.clickhouse.persistence.enabled }}
8275
volumes:
8376
{{- if .Values.clickhouse.persistence.existingClaim }}

charts/posthog/templates/events-deployment.yaml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ spec:
1818
metadata:
1919
annotations:
2020
checksum/secrets.yaml: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }}
21-
{{- if .Values.web.podAnnotations }}
22-
{{ toYaml .Values.web.podAnnotations | indent 8 }}
21+
{{- if .Values.events.podAnnotations }}
22+
{{ toYaml .Values.events.podAnnotations | indent 8 }}
2323
{{- end }}
2424
labels:
2525
app: {{ template "posthog.fullname" . }}
@@ -34,18 +34,9 @@ spec:
3434
spec:
3535
terminationGracePeriodSeconds: {{ include "snippet.web-deployments.terminationGracePeriodSeconds" . }}
3636
serviceAccountName: {{ template "posthog.serviceAccountName" . }}
37-
{{- if .Values.web.affinity }}
38-
affinity:
39-
{{ toYaml .Values.web.affinity | indent 8 }}
40-
{{- end }}
41-
{{- if .Values.web.nodeSelector }}
42-
nodeSelector:
43-
{{ toYaml .Values.web.nodeSelector | indent 8 }}
44-
{{- end }}
45-
{{- if .Values.web.tolerations }}
46-
tolerations:
47-
{{ toYaml .Values.web.tolerations | indent 8 }}
48-
{{- end }}
37+
affinity: {{ toYaml (merge .Values.events.affinity .Values.affinity) | nindent 8 }}
38+
nodeSelector: {{ toYaml (merge .Values.events.nodeSelector .Values.nodeSelector) | nindent 8 }}
39+
tolerations: {{ toYaml (coalesce .Values.events.tolerations .Values.tolerations) | nindent 8 }}
4940
{{- if .Values.web.schedulerName }}
5041
schedulerName: "{{ .Values.web.schedulerName }}"
5142
{{- end }}
@@ -141,7 +132,7 @@ spec:
141132
timeoutSeconds: {{ .Values.web.startupProbe.timeoutSeconds }}
142133
resources:
143134
{{ if not .Values.events.resources }}
144-
{{ toYaml .Values.web.resources | indent 12 }}
135+
{{ toYaml .Values.events.resources | indent 12 }}
145136
{{ else }}
146137
{{ toYaml .Values.events.resources | indent 12 }}
147138
{{ end }}

charts/posthog/templates/migrate.job.yaml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,9 @@ spec:
2121
{{ toYaml .Values.worker.podLabels | indent 8 }}
2222
{{- end }}
2323
spec:
24-
{{- with .Values.hooks.affinity }}
25-
affinity:
26-
{{ toYaml . | indent 8 }}
27-
{{- end }}
28-
{{- with .Values.hooks.nodeSelector }}
29-
nodeSelector:
30-
{{ toYaml . | indent 8 }}
31-
{{- end }}
32-
{{- with .Values.hooks.tolerations }}
33-
tolerations:
34-
{{ toYaml . | indent 8 }}
35-
{{- end }}
24+
affinity: {{ toYaml (merge .Values.hooks.affinity .Values.affinity) | nindent 8 }}
25+
nodeSelector: {{ toYaml (merge .Values.hooks.nodeSelector .Values.nodeSelector) | nindent 8 }}
26+
tolerations: {{ toYaml (coalesce .Values.hooks.tolerations .Values.tolerations) | nindent 8 }}
3627
restartPolicy: Never
3728
{{- if .Values.image.imagePullSecrets }}
3829
imagePullSecrets:

charts/posthog/templates/pgbouncer-deployment.yaml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,10 @@ spec:
4040
# shuts down and exits before the terminationGracePeriod is done, we
4141
# moves to the next step immediately.
4242
terminationGracePeriodSeconds: 65
43-
4443
serviceAccountName: {{ template "posthog.serviceAccountName" . }}
45-
{{- if .Values.pgbouncer.affinity }}
46-
affinity: {{ toYaml .Values.pgbouncer.affinity | nindent 8 }}
47-
{{- end }}
48-
{{- if .Values.pgbouncer.nodeSelector }}
49-
nodeSelector: {{ toYaml .Values.pgbouncer.nodeSelector | nindent 8 }}
50-
{{- end }}
51-
{{- if .Values.pgbouncer.tolerations }}
52-
tolerations: {{ toYaml .Values.pgbouncer.tolerations | nindent 8 }}
53-
{{- end }}
44+
affinity: {{ toYaml (merge .Values.pgbouncer.affinity .Values.affinity) | nindent 8 }}
45+
nodeSelector: {{ toYaml (merge .Values.pgbouncer.nodeSelector .Values.nodeSelector) | nindent 8 }}
46+
tolerations: {{ toYaml (coalesce .Values.pgbouncer.tolerations .Values.tolerations) | nindent 8 }}
5447
{{- if .Values.pgbouncer.schedulerName }}
5548
schedulerName: "{{ .Values.pgbouncer.schedulerName }}"
5649
{{- end }}

charts/posthog/templates/web-deployment.yaml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,9 @@ spec:
3434
spec:
3535
terminationGracePeriodSeconds: {{ include "snippet.web-deployments.terminationGracePeriodSeconds" . }}
3636
serviceAccountName: {{ template "posthog.serviceAccountName" . }}
37-
{{- if .Values.web.affinity }}
38-
affinity:
39-
{{ toYaml .Values.web.affinity | indent 8 }}
40-
{{- end }}
41-
{{- if .Values.web.nodeSelector }}
42-
nodeSelector:
43-
{{ toYaml .Values.web.nodeSelector | indent 8 }}
44-
{{- end }}
45-
{{- if .Values.web.tolerations }}
46-
tolerations:
47-
{{ toYaml .Values.web.tolerations | indent 8 }}
48-
{{- end }}
37+
affinity: {{ toYaml (merge .Values.web.affinity .Values.affinity) | nindent 8 }}
38+
nodeSelector: {{ toYaml (merge .Values.web.nodeSelector .Values.nodeSelector) | nindent 8 }}
39+
tolerations: {{ toYaml (coalesce .Values.web.tolerations .Values.tolerations) | nindent 8 }}
4940
{{- if .Values.web.schedulerName }}
5041
schedulerName: "{{ .Values.web.schedulerName }}"
5142
{{- end }}

charts/posthog/templates/worker-deployment.yaml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,9 @@ spec:
3333
{{- end }}
3434
spec:
3535
serviceAccountName: {{ template "posthog.serviceAccountName" . }}
36-
{{- if .Values.worker.affinity }}
37-
affinity:
38-
{{ toYaml .Values.worker.affinity | indent 8 }}
39-
{{- end }}
40-
{{- if .Values.worker.nodeSelector }}
41-
nodeSelector:
42-
{{ toYaml .Values.worker.nodeSelector | indent 8 }}
43-
{{- end }}
44-
{{- if .Values.worker.tolerations }}
45-
tolerations:
46-
{{ toYaml .Values.worker.tolerations | indent 8 }}
47-
{{- end }}
36+
affinity: {{ toYaml (merge .Values.worker.affinity .Values.affinity) | nindent 8 }}
37+
nodeSelector: {{ toYaml (merge .Values.worker.nodeSelector .Values.nodeSelector) | nindent 8 }}
38+
tolerations: {{ toYaml (coalesce .Values.worker.tolerations .Values.tolerations) | nindent 8 }}
4839
{{- if .Values.worker.schedulerName }}
4940
schedulerName: "{{ .Values.worker.schedulerName }}"
5041
{{- end }}

charts/posthog/tests/__snapshot__/clickhouse-instance.yaml.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ the manifest should match the snapshot when using default values:
7070
podTemplates:
7171
- name: pod-template
7272
spec:
73+
affinity: {}
7374
containers:
7475
- command:
7576
- /bin/bash
@@ -87,10 +88,12 @@ the manifest should match the snapshot when using default values:
8788
volumeMounts:
8889
- mountPath: /var/lib/clickhouse
8990
name: data-volumeclaim-template
91+
nodeSelector: {}
9092
securityContext:
9193
fsGroup: 101
9294
runAsGroup: 101
9395
runAsUser: 101
96+
tolerations: null
9497
volumes:
9598
- name: data-volumeclaim-template
9699
persistentVolumeClaim:

charts/posthog/tests/__snapshot__/pgbouncer-deployment.yaml.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
should match snapshot data:
22
1: |
3+
affinity: {}
34
containers:
45
- env:
56
- name: POSTGRESQL_USERNAME
@@ -54,5 +55,7 @@ should match snapshot data:
5455
tcpSocket:
5556
port: 6543
5657
timeoutSeconds: 2
58+
nodeSelector: {}
5759
serviceAccountName: RELEASE-NAME-posthog
5860
terminationGracePeriodSeconds: 65
61+
tolerations: null

0 commit comments

Comments
 (0)