-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy path_snippet-plugins-deployment.tpl
183 lines (166 loc) · 6.64 KB
/
_snippet-plugins-deployment.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# An abstract deployment / hpa pair for defining the plugin-server deployments.
# This may be an abstraction too far so if you end up putting loads of if
# statements in here then it's worth considering restructuring.
{{ define "plugins-deployment" }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "posthog.fullname" .root }}-{{ .name }}
labels: {{- include "_snippet-metadata-labels-common" .root | nindent 4 }}
annotations: {{- include "_snippet-metadata-annotations-common" .root | nindent 4 }}
spec:
selector:
matchLabels:
app: {{ template "posthog.fullname" .root }}
release: "{{ .root.Release.Name }}"
role: {{ .name }}
{{- if not .params.hpa.enabled }}
replicas: {{ .params.replicacount }}
{{- end }}
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: {{ .params.rollout.maxSurge }}
maxUnavailable: {{ .params.rollout.maxUnavailable }}
template:
metadata:
annotations:
checksum/secrets.yaml: {{ include (print $.root.Template.BasePath "/secrets.yaml") .root | sha256sum }}
{{- if .params.podAnnotations }}
{{- toYaml .params.podAnnotations | nindent 8 }}
{{- end }}
labels:
app: {{ template "posthog.fullname" .root }}
release: "{{ .root.Release.Name }}"
role: {{ .name }}
{{- if (eq (default .root.Values.image.tag "none") "latest") }}
date: "{{ now | unixEpoch }}"
{{- end }}
{{- if .params.podLabels }}
{{- toYaml .params.podLabels | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "posthog.serviceAccountName" .root }}
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 }}
{{- if .params.priorityClassName }}
priorityClassName: "{{ .params.priorityClassName }}"
{{- end }}
{{- if .root.Values.image.imagePullSecrets }}
imagePullSecrets:
{{- toYaml .root.Values.image.imagePullSecrets | nindent 8 }}
{{- end }}
# I do not know for sure if the old one has been used anywhere, so do both :(
{{- if .root.Values.image.pullSecrets }}
imagePullSecrets:
{{- range .root.Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- if .params.podSecurityContext.enabled }}
securityContext: {{- omit .params.podSecurityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
containers:
- name: {{ .root.Chart.Name }}-{{ .name }}
image: {{ template "posthog.image.fullPath" .root }}
imagePullPolicy: {{ .root.Values.image.pullPolicy }}
command:
- ./bin/plugin-server
- --no-restart-loop
ports:
# Expose the port on which the healtchheck endpoint listens
- containerPort: 6738
env:
{{ if .mode }}
- name: PLUGIN_SERVER_MODE
value: {{ .mode }}
{{ end }}
- name: SENTRY_DSN
value: {{ .params.sentryDSN | default .root.Values.sentryDSN }}
# Kafka env variables
{{- include "snippet.kafka-env" .root | nindent 8 }}
# Object Storage env variables
{{- include "snippet.objectstorage-env" .root | nindent 8 }}
# Redis env variables
{{- include "snippet.redis-env" .root | nindent 8 }}
# statsd env variables
{{- include "snippet.statsd-env" .root | nindent 8 }}
{{- include "snippet.posthog-env" .root | indent 8 }}
{{- include "snippet.postgresql-env" .root | nindent 8 }}
{{- include "snippet.clickhouse-env" .root | nindent 8 }}
{{- if .root.Values.env }}
{{- toYaml .root.Values.env | nindent 8 }}
{{- end }}
{{- if .params.env }}
{{- toYaml .params.env | nindent 8 }}
{{- end }}
livenessProbe:
exec:
command:
# Just check that we can at least exec to the container
- "true"
failureThreshold: {{ .params.livenessProbe.failureThreshold }}
initialDelaySeconds: {{ .params.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .params.livenessProbe.periodSeconds }}
successThreshold: {{ .params.livenessProbe.successThreshold }}
timeoutSeconds: {{ .params.livenessProbe.timeoutSeconds }}
readinessProbe:
failureThreshold: {{ .params.readinessProbe.failureThreshold }}
httpGet:
path: /_health
port: 6738
scheme: HTTP
initialDelaySeconds: {{ .params.readinessProbe.initialDelaySeconds }}
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 }}
securityContext:
{{- omit .params.securityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
initContainers:
{{- include "_snippet-initContainers-wait-for-service-dependencies" .root | indent 8 }}
{{- include "_snippet-initContainers-wait-for-migrations" .root | indent 8 }}
---
{{ if .params.hpa.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "posthog.fullname" .root }}-{{ .name }}
labels: {{- include "_snippet-metadata-labels-common" .root | nindent 4 }}
spec:
scaleTargetRef:
kind: Deployment
apiVersion: apps/v1
name: {{ template "posthog.fullname" .root }}-{{ .name }}
minReplicas: {{ .params.hpa.minpods }}
maxReplicas: {{ .params.hpa.maxpods }}
metrics:
{{- with .params.hpa.cputhreshold }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
behavior:
{{ toYaml .params.hpa.behavior | nindent 4 }}
{{- end }}
{{ end }}