Skip to content

Commit

Permalink
Merge f37c58d into cd66e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
frankh authored Oct 30, 2023
2 parents cd66e2e + f37c58d commit 28fd190
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/posthog/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 30.32.0
version: 30.33.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
Expand Down
1 change: 1 addition & 0 deletions charts/posthog/templates/_snippet-plugins-deployment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ spec:
{{- end }}
spec:
serviceAccountName: {{ template "posthog.serviceAccountName" .root }}
{{- include "_snippet-topologySpreadConstraints" .root | nindent 6 }}

{{- if .params.affinity }}
affinity:
Expand Down
36 changes: 36 additions & 0 deletions charts/posthog/templates/_snippet-topologySpreadConstraints.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{/* Common topologySpreadConstraints definition */}}
{{/*
matchLabelsKeys are the set of unique pod labels for which the constraints are applied
any missing labels are ignored.
pod-template-hash is added automatically by deployments and is unique for each rollout.
Including this means we don't get out of sync on rollouts as it ignores the locations
of existing pods that will be terminated after the rollout is finished.
*/}}
{{- define "_snippet-selectors" -}}
labelSelector:
matchLabels: {}
matchLabelKeys:
- pod-template-hash
- app
- release
- role
- app.kubernetes.io/name
- app.kubernetes.io/instance
{{- end }}
{{- define "_snippet-topologySpreadConstraints" }}
{{- if (.Values.includeDefaultTopologySpreadConstraints | default false) }}
topologySpreadConstraints:
- maxSkew: 1
minDomains: 3
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
nodeTaintsPolicy: Honor
{{- include "_snippet-selectors" . | nindent 2 }}
- maxSkew: 3
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
nodeTaintsPolicy: Honor
{{- include "_snippet-selectors" . | nindent 2 }}
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions charts/posthog/templates/decide-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ spec:
spec:
terminationGracePeriodSeconds: {{ include "snippet.web-deployments.terminationGracePeriodSeconds" . }}
serviceAccountName: {{ template "posthog.serviceAccountName" . }}
{{- include "_snippet-topologySpreadConstraints" . | nindent 6 }}

{{- if .Values.web.affinity }}
affinity:
Expand Down
1 change: 1 addition & 0 deletions charts/posthog/templates/events-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ spec:
spec:
terminationGracePeriodSeconds: {{ include "snippet.web-deployments.terminationGracePeriodSeconds" . }}
serviceAccountName: {{ template "posthog.serviceAccountName" . }}
{{- include "_snippet-topologySpreadConstraints" . | nindent 6 }}

{{- if .Values.web.affinity }}
affinity:
Expand Down
1 change: 1 addition & 0 deletions charts/posthog/templates/pgbouncer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ spec:
terminationGracePeriodSeconds: 65

serviceAccountName: {{ template "posthog.serviceAccountName" . }}
{{- include "_snippet-topologySpreadConstraints" . | nindent 6 }}

{{- if .Values.pgbouncer.affinity }}
affinity: {{ toYaml .Values.pgbouncer.affinity | nindent 8 }}
Expand Down
1 change: 1 addition & 0 deletions charts/posthog/templates/pgbouncer-read-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ spec:
terminationGracePeriodSeconds: 65

serviceAccountName: {{ template "posthog.serviceAccountName" . }}
{{- include "_snippet-topologySpreadConstraints" . | nindent 6 }}

{{- if .Values.pgbouncerRead.affinity }}
affinity: {{ toYaml .Values.pgbouncerRead.affinity | nindent 8 }}
Expand Down
1 change: 1 addition & 0 deletions charts/posthog/templates/recordings-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ spec:
spec:
terminationGracePeriodSeconds: {{ include "snippet.web-deployments.terminationGracePeriodSeconds" . }}
serviceAccountName: {{ template "posthog.serviceAccountName" . }}
{{- include "_snippet-topologySpreadConstraints" . | nindent 6 }}

{{- if .Values.web.affinity }}
affinity:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ spec:
spec:
terminationGracePeriodSeconds: {{ .Values.temporalPyWorker.terminationGracePeriodSeconds }}
serviceAccountName: {{ template "posthog.serviceAccountName" . }}
{{- include "_snippet-topologySpreadConstraints" . | nindent 6 }}

{{- if .Values.temporalPyWorker.affinity }}
affinity:
Expand Down
1 change: 1 addition & 0 deletions charts/posthog/templates/web-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ spec:
spec:
terminationGracePeriodSeconds: {{ include "snippet.web-deployments.terminationGracePeriodSeconds" . }}
serviceAccountName: {{ template "posthog.serviceAccountName" . }}
{{- include "_snippet-topologySpreadConstraints" . | nindent 6 }}

{{- if .Values.web.affinity }}
affinity:
Expand Down
1 change: 1 addition & 0 deletions charts/posthog/templates/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ spec:
{{- end }}
spec:
serviceAccountName: {{ template "posthog.serviceAccountName" . }}
{{- include "_snippet-topologySpreadConstraints" . | nindent 6 }}

{{- if .Values.worker.affinity }}
affinity:
Expand Down
42 changes: 42 additions & 0 deletions charts/posthog/tests/_topologySpreadConstraints.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
suite: _topologySpreadConstraints
templates:
- templates/plugins-deployment.yaml
- templates/web-deployment.yaml
- templates/worker-deployment.yaml

tests:
- it: spec.template.spec.topologySpreadConstraints should be empty by default
templates:
- templates/plugins-deployment.yaml
- templates/web-deployment.yaml
- templates/worker-deployment.yaml
set:
cloud: local
asserts:
- hasDocuments:
count: 1
- isEmpty:
path: spec.template.spec.topologySpreadConstraints
- it: spec.template.spec.topologySpreadConstraints should exist if includeDefaultTopologySpreadConstraints is set
templates:
- templates/plugins-deployment.yaml
- templates/web-deployment.yaml
- templates/worker-deployment.yaml
set:
cloud: local
includeDefaultTopologySpreadConstraints: true
asserts:
- hasDocuments:
count: 1
- contains:
path: spec.template.spec.topologySpreadConstraints[0]
content:
topologyKey: topology.kubernetes.io/zone
maxSkew: 1
whenUnsatisfiable: DoNotSchedule
- contains:
path: spec.template.spec.topologySpreadConstraints[1]
content:
topologyKey: topology.kubernetes.io/hostname
maxSkew: 3
whenUnsatisfiable: ScheduleAnyway
4 changes: 4 additions & 0 deletions charts/posthog/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3396,3 +3396,7 @@ busybox:

# -- Kubernetes cluster domain name
clusterDomain: cluster.local

# Whether to set a topologySpreadConstraint on all deployments
# to balance pods between availability zones and nodes
includeDefaultTopologySpreadConstraints: false

0 comments on commit 28fd190

Please sign in to comment.