Skip to content

Commit 3634ca6

Browse files
authored
feat: add toolbox deploy (PostHog#741)
1 parent d16a979 commit 3634ca6

File tree

5 files changed

+92
-2
lines changed

5 files changed

+92
-2
lines changed

charts/posthog/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type: application
1111

1212
# This is the chart version. This version number should be incremented each time you make changes
1313
# to the chart and its templates, including the app version.
14-
version: 30.21.0
14+
version: 30.22.0
1515

1616
# This is the version number of the application being deployed. This version number should be
1717
# incremented each time you make changes to the application.

charts/posthog/templates/_snippet-metadata-labels-common.tpl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@
55
- https://helm.sh/docs/chart_best_practices/labels/#standard-labels
66
- https://kubernetes.io/docs/concepts/overview/_print/#labels
77
*/}}
8-
{{- define "_snippet-metadata-labels-common" }}
8+
9+
{{- define "_snippet-metadata-labels-constants" }}
910
"app.kubernetes.io/name": {{ include "posthog.fullname" . | quote }}
1011
"app.kubernetes.io/instance": {{ .Release.Name | quote }}
1112
"app.kubernetes.io/managed-by": {{ .Release.Service | quote }}
13+
{{- end }}
14+
15+
{{- define "_snippet-metadata-labels-common" }}
16+
{{- include "_snippet-metadata-labels-constants" . }}
1217
"helm.sh/chart": {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" | quote }}
1318
{{- end }}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{{- if .Values.toolbox.enabled -}}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ template "posthog.fullname" . }}-toolbox
6+
labels: {{- include "_snippet-metadata-labels-constants" . | nindent 4 }}
7+
annotations: {{- include "_snippet-metadata-annotations-common" . | nindent 4 }}
8+
spec:
9+
selector:
10+
matchLabels:
11+
app: {{ template "posthog.fullname" . }}
12+
release: "{{ .Release.Name }}"
13+
role: toolbox
14+
15+
template:
16+
metadata:
17+
labels:
18+
app: {{ template "posthog.fullname" . }}
19+
release: "{{ .Release.Name }}"
20+
role: toolbox
21+
spec:
22+
serviceAccountName: {{ template "posthog.serviceAccountName" . }}
23+
containers:
24+
- name: {{ .Chart.Name }}-toolbox
25+
# We are specifying the image by tag to avoid restarts on chart apply.
26+
# Users will need to k delete pod to pull the newest image.
27+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
28+
imagePullPolicy: Always
29+
command:
30+
- sleep
31+
- infinity
32+
env:
33+
{{- include "snippet.kafka-env" . | indent 8 }}
34+
{{- include "snippet.objectstorage-env" . | indent 8 }}
35+
{{- include "snippet.redis-env" . | indent 8 }}
36+
{{- include "snippet.posthog-env" . | indent 8 }}
37+
{{- include "snippet.postgresql-env" . | nindent 8 }}
38+
{{- include "snippet.clickhouse-env" . | nindent 8 }}
39+
{{- include "snippet.email-env" . | nindent 8 }}
40+
- name: PRIMARY_DB
41+
value: clickhouse
42+
{{- if .Values.env }}
43+
{{ toYaml .Values.env | indent 8 }}
44+
{{- end }}
45+
{{- if .Values.toolbox.env }}
46+
{{ toYaml .Values.toolbox.env | indent 8 }}
47+
{{- end }}
48+
resources:
49+
{{ toYaml .Values.toolbox.resources | indent 12 }}
50+
{{- end }}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
suite: PostHog toolbox deployment definition
2+
templates:
3+
- templates/toolbox-deployment.yaml
4+
- templates/secrets.yaml
5+
6+
tests:
7+
- it: should be empty if toolbox.enabled is set to false
8+
template: templates/toolbox-deployment.yaml # TODO: remove once secrets.yaml will be fixed/removed
9+
set:
10+
cloud: local # TODO: remove once secrets.yaml will be fixed/removed
11+
toolbox.enabled: false
12+
asserts:
13+
- hasDocuments:
14+
count: 0
15+
16+
- it: should not use image by sha
17+
template: templates/toolbox-deployment.yaml
18+
set:
19+
cloud: local
20+
toolbox.enabled: true
21+
image.repository: posthog/posthog
22+
image.sha: ignored
23+
image.tag: latest
24+
asserts:
25+
- equal:
26+
path: spec.template.spec.containers[0].image
27+
value: posthog/posthog:latest

charts/posthog/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,14 @@ pluginsScheduler:
10871087
# -- Sentry endpoint to send errors to. Falls back to global sentryDSN
10881088
sentryDSN:
10891089

1090+
toolbox:
1091+
# -- Whether to install the PostHog toolbox deployment
1092+
enabled: false
1093+
# -- Additional env variables to inject into the toolbox deployment.
1094+
env: []
1095+
# -- Resource limits for the toolbox deployment.
1096+
resources: {}
1097+
10901098
temporalPyWorker:
10911099
# -- Whether to install the PostHog Temporal Python worker stack or not.
10921100
enabled: false

0 commit comments

Comments
 (0)