Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add global nodeSelector, tolerations and affinity #620

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions charts/posthog/ALL_VALUES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ The following table lists the configurable parameters of the PostHog chart and t
| 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. |
| posthogSecretKey.existingSecretKey | string | `"posthog-secret"` | Specify the key within the secret from which SECRET_KEY should be taken. |
| env | list | `[]` | Environment variables to inject into every PostHog deployment. |
| nodeSelector | object | `{}` | Global Node labels for all deployment. |
| tolerations | list | `[]` | Global Toleration labels for all deployment. |
| affinity | object | `{}` | Global Affinity settings for all deployment. |
| migrate.enabled | bool | `true` | Whether to install the PostHog migrate job or not. |
| events.enabled | bool | `true` | Whether to install the PostHog events stack or not. |
| events.replicacount | int | `1` | Count of events pods to run. This setting is ignored if `events.hpa.enabled` is set to `true`. |
Expand Down
6 changes: 3 additions & 3 deletions charts/posthog/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies:
version: 16.8.9
- name: zookeeper
repository: https://raw.githubusercontent.com/bitnami/charts/pre-2022/bitnami
version: 7.0.5
version: 7.4.11
- name: grafana
repository: https://grafana.github.io/helm-charts
version: 6.40.0
Expand All @@ -44,5 +44,5 @@ dependencies:
- name: prometheus-statsd-exporter
repository: https://prometheus-community.github.io/helm-charts
version: 0.3.1
digest: sha256:5ac223659ced28c44ff2c89963e0268427f848b5d4db98df9b8f1010f22f8207
generated: "2022-12-20T11:35:36.888806538Z"
digest: sha256:5615fc5fda7592b7c87d352789702c33db0ec6c6ff8625aee1ef20465aaa442f
generated: "2023-02-17T16:38:29.581158+05:00"
2 changes: 1 addition & 1 deletion charts/posthog/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies:
condition: redis.enabled

- name: zookeeper
version: 7.0.5
version: 7.4.11
repository: https://raw.githubusercontent.com/bitnami/charts/pre-2022/bitnami
condition: zookeeper.enabled

Expand Down
Binary file removed charts/posthog/charts/zookeeper-7.0.5.tgz
Binary file not shown.
Binary file added charts/posthog/charts/zookeeper-7.4.11.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion charts/posthog/templates/_kafka.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{{/* Return the Kafka hosts (brokers) */}}
{{- define "posthog.kafka.brokers"}}
{{- if .Values.kafka.enabled -}}
{{- printf "%s:%d" (include "posthog.kafka.fullname" .) (.Values.kafka.service.port | int) }}
{{- printf "%s:%d" (include "posthog.kafka.fullname" .) (.Values.kafka.service.ports.client | int) }}
{{- else -}}
{{- printf "%s" .Values.externalKafka.brokers }}
{{- end }}
Expand Down
31 changes: 14 additions & 17 deletions charts/posthog/templates/_snippet-plugins-deployment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,9 @@ spec:
{{- end }}
spec:
serviceAccountName: {{ template "posthog.serviceAccountName" .root }}

{{- if .params.affinity }}
affinity:
{{- toYaml .params.affinity | nindent 8 }}
{{- end }}

{{- if .params.nodeSelector }}
nodeSelector:
{{- toYaml .params.nodeSelector | nindent 8 }}
{{- end }}

{{- if .params.tolerations }}
tolerations:
{{- toYaml .params.tolerations | nindent 8 }}
{{- end }}

affinity: {{ toYaml (merge .params.affinity .root.Values.affinity) | nindent 8 }}
nodeSelector: {{ toYaml (merge .params.nodeSelector .root.Values.nodeSelector) | nindent 8 }}
tolerations: {{ toYaml (coalesce .params.tolerations .root.Values.tolerations) | nindent 8 }}
{{- if .params.schedulerName }}
schedulerName: "{{ .params.schedulerName }}"
{{- end }}
Expand Down Expand Up @@ -145,6 +132,16 @@ spec:
periodSeconds: {{ .params.readinessProbe.periodSeconds }}
successThreshold: {{ .params.readinessProbe.successThreshold }}
timeoutSeconds: {{ .params.readinessProbe.timeoutSeconds }}
startupProbe:
failureThreshold: {{ .params.startupProbe.failureThreshold }}
httpGet:
path: /_health
port: 6738
scheme: HTTP
initialDelaySeconds: {{ .params.startupProbe.initialDelaySeconds }}
periodSeconds: {{ .params.startupProbe.periodSeconds }}
successThreshold: {{ .params.startupProbe.successThreshold }}
timeoutSeconds: {{ .params.startupProbe.timeoutSeconds }}
resources:
{{- toYaml .params.resources | nindent 12 }}
{{- if .params.securityContext.enabled }}
Expand All @@ -158,7 +155,7 @@ spec:
---

{{ if .params.hpa.enabled }}
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "posthog.fullname" .root }}-{{ .name }}
Expand Down
3 changes: 3 additions & 0 deletions charts/posthog/templates/clickhouse-backup-cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ spec:
{{- end }}
{{- end }}
{{- end }}
affinity: {{ toYaml (merge .Values.clickhouse.affinity .Values.affinity) | nindent 12 }}
nodeSelector: {{ toYaml (merge .Values.clickhouse.nodeSelector .Values.nodeSelector) | nindent 12 }}
tolerations: {{ toYaml (coalesce .Values.clickhouse.tolerations .Values.tolerations) | nindent 12 }}

initContainers:
#
Expand Down
13 changes: 3 additions & 10 deletions charts/posthog/templates/clickhouse_instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,9 @@ spec:
podDistribution: {{ toYaml .Values.clickhouse.podDistribution | nindent 12 }}
{{- end}}
spec:
{{- if .Values.clickhouse.affinity }}
affinity: {{ toYaml .Values.clickhouse.affinity | nindent 12 }}
{{- end }}
{{- if .Values.clickhouse.tolerations }}
tolerations: {{ toYaml .Values.clickhouse.tolerations | nindent 12 }}
{{- end }}
{{- if .Values.clickhouse.nodeSelector }}
nodeSelector: {{ toYaml .Values.clickhouse.nodeSelector | nindent 12 }}
{{- end }}

affinity: {{ toYaml (merge .Values.clickhouse.affinity .Values.affinity) | nindent 12 }}
nodeSelector: {{ toYaml (merge .Values.clickhouse.nodeSelector .Values.nodeSelector) | nindent 12 }}
tolerations: {{ toYaml (coalesce .Values.clickhouse.tolerations .Values.tolerations) | nindent 12 }}
{{- if .Values.clickhouse.persistence.enabled }}
volumes:
{{- if .Values.clickhouse.persistence.existingClaim }}
Expand Down
23 changes: 5 additions & 18 deletions charts/posthog/templates/events-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ spec:
metadata:
annotations:
checksum/secrets.yaml: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }}
{{- if .Values.web.podAnnotations }}
{{ toYaml .Values.web.podAnnotations | indent 8 }}
{{- if .Values.events.podAnnotations }}
{{ toYaml .Values.events.podAnnotations | indent 8 }}
{{- end }}
labels:
app: {{ template "posthog.fullname" . }}
Expand All @@ -41,22 +41,9 @@ spec:
spec:
terminationGracePeriodSeconds: {{ include "snippet.web-deployments.terminationGracePeriodSeconds" . }}
serviceAccountName: {{ template "posthog.serviceAccountName" . }}

{{- if .Values.web.affinity }}
affinity:
{{ toYaml .Values.web.affinity | indent 8 }}
{{- end }}

{{- if .Values.web.nodeSelector }}
nodeSelector:
{{ toYaml .Values.web.nodeSelector | indent 8 }}
{{- end }}

{{- if .Values.web.tolerations }}
tolerations:
{{ toYaml .Values.web.tolerations | indent 8 }}
{{- end }}

affinity: {{ toYaml (merge .Values.events.affinity .Values.affinity) | nindent 8 }}
nodeSelector: {{ toYaml (merge .Values.events.nodeSelector .Values.nodeSelector) | nindent 8 }}
tolerations: {{ toYaml (coalesce .Values.events.tolerations .Values.tolerations) | nindent 8 }}
{{- if .Values.web.schedulerName }}
schedulerName: "{{ .Values.web.schedulerName }}"
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/posthog/templates/events-hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if and .Values.events.enabled .Values.events.hpa.enabled -}}
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "posthog.fullname" . }}-events
Expand Down
20 changes: 4 additions & 16 deletions charts/posthog/templates/migrate.job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,16 @@ spec:
{{ toYaml .Values.worker.podLabels | indent 8 }}
{{- end }}
spec:
{{- with .Values.hooks.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}

{{- with .Values.hooks.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}

{{- with .Values.hooks.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}

affinity: {{ toYaml (merge .Values.hooks.affinity .Values.affinity) | nindent 8 }}
nodeSelector: {{ toYaml (merge .Values.hooks.nodeSelector .Values.nodeSelector) | nindent 8 }}
tolerations: {{ toYaml (coalesce .Values.hooks.tolerations .Values.tolerations) | nindent 8 }}
restartPolicy: Never

{{- if .Values.image.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.image.imagePullSecrets | indent 8 }}
{{- end }}

# I do not know for sure if the old one has been used anywhere, so do both :(
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
Expand Down
17 changes: 3 additions & 14 deletions charts/posthog/templates/pgbouncer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,10 @@ spec:
# shuts down and exits before the terminationGracePeriod is done, we
# moves to the next step immediately.
terminationGracePeriodSeconds: 65

serviceAccountName: {{ template "posthog.serviceAccountName" . }}

{{- if .Values.pgbouncer.affinity }}
affinity: {{ toYaml .Values.pgbouncer.affinity | nindent 8 }}
{{- end }}

{{- if .Values.pgbouncer.nodeSelector }}
nodeSelector: {{ toYaml .Values.pgbouncer.nodeSelector | nindent 8 }}
{{- end }}

{{- if .Values.pgbouncer.tolerations }}
tolerations: {{ toYaml .Values.pgbouncer.tolerations | nindent 8 }}
{{- end }}

affinity: {{ toYaml (merge .Values.pgbouncer.affinity .Values.affinity) | nindent 8 }}
nodeSelector: {{ toYaml (merge .Values.pgbouncer.nodeSelector .Values.nodeSelector) | nindent 8 }}
tolerations: {{ toYaml (coalesce .Values.pgbouncer.tolerations .Values.tolerations) | nindent 8 }}
{{- if .Values.pgbouncer.schedulerName }}
schedulerName: "{{ .Values.pgbouncer.schedulerName }}"
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/posthog/templates/pgbouncer-hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if and .Values.pgbouncer.enabled .Values.pgbouncer.hpa.enabled -}}
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "posthog.fullname" . }}-pgbouncer
Expand Down
19 changes: 3 additions & 16 deletions charts/posthog/templates/web-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,9 @@ spec:
spec:
terminationGracePeriodSeconds: {{ include "snippet.web-deployments.terminationGracePeriodSeconds" . }}
serviceAccountName: {{ template "posthog.serviceAccountName" . }}

{{- if .Values.web.affinity }}
affinity:
{{ toYaml .Values.web.affinity | indent 8 }}
{{- end }}

{{- if .Values.web.nodeSelector }}
nodeSelector:
{{ toYaml .Values.web.nodeSelector | indent 8 }}
{{- end }}

{{- if .Values.web.tolerations }}
tolerations:
{{ toYaml .Values.web.tolerations | indent 8 }}
{{- end }}

affinity: {{ toYaml (merge .Values.web.affinity .Values.affinity) | nindent 8 }}
nodeSelector: {{ toYaml (merge .Values.web.nodeSelector .Values.nodeSelector) | nindent 8 }}
tolerations: {{ toYaml (coalesce .Values.web.tolerations .Values.tolerations) | nindent 8 }}
{{- if .Values.web.schedulerName }}
schedulerName: "{{ .Values.web.schedulerName }}"
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/posthog/templates/web-hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if and .Values.web.enabled .Values.web.hpa.enabled -}}
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "posthog.fullname" . }}-web
Expand Down
19 changes: 3 additions & 16 deletions charts/posthog/templates/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,9 @@ spec:
{{- end }}
spec:
serviceAccountName: {{ template "posthog.serviceAccountName" . }}

{{- if .Values.worker.affinity }}
affinity:
{{ toYaml .Values.worker.affinity | indent 8 }}
{{- end }}

{{- if .Values.worker.nodeSelector }}
nodeSelector:
{{ toYaml .Values.worker.nodeSelector | indent 8 }}
{{- end }}

{{- if .Values.worker.tolerations }}
tolerations:
{{ toYaml .Values.worker.tolerations | indent 8 }}
{{- end }}

affinity: {{ toYaml (merge .Values.worker.affinity .Values.affinity) | nindent 8 }}
nodeSelector: {{ toYaml (merge .Values.worker.nodeSelector .Values.nodeSelector) | nindent 8 }}
tolerations: {{ toYaml (coalesce .Values.worker.tolerations .Values.tolerations) | nindent 8 }}
{{- if .Values.worker.schedulerName }}
schedulerName: "{{ .Values.worker.schedulerName }}"
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/posthog/templates/worker-hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if and .Values.worker.enabled .Values.worker.hpa.enabled -}}
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "posthog.fullname" . }}-worker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ should match the snapshot when backup is true:
labels:
job: clickhouse-backup
spec:
affinity: {}
containers:
- command:
- /bin/sh
Expand Down Expand Up @@ -67,7 +68,9 @@ should match the snapshot when backup is true:
image: busybox:1.34
imagePullPolicy: IfNotPresent
name: wait-for-service-dependencies
nodeSelector: {}
restartPolicy: Never
tolerations: null
volumes:
- configMap:
defaultMode: 511
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ the manifest should match the snapshot when using default values:
podTemplates:
- name: pod-template
spec:
affinity: {}
containers:
- command:
- /bin/bash
Expand All @@ -87,10 +88,12 @@ the manifest should match the snapshot when using default values:
volumeMounts:
- mountPath: /var/lib/clickhouse
name: data-volumeclaim-template
nodeSelector: {}
securityContext:
fsGroup: 101
runAsGroup: 101
runAsUser: 101
tolerations: null
volumes:
- name: data-volumeclaim-template
persistentVolumeClaim:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
should match snapshot data:
1: |
affinity: {}
containers:
- env:
- name: POSTGRESQL_USERNAME
Expand Down Expand Up @@ -54,5 +55,7 @@ should match snapshot data:
tcpSocket:
port: 6543
timeoutSeconds: 2
nodeSelector: {}
serviceAccountName: RELEASE-NAME-posthog
terminationGracePeriodSeconds: 65
tolerations: null
Loading