blob: d0846ecf739b7ae563b33fdad55f655abf1d5117 [file] [log] [blame]
gio932849f2024-08-02 09:01:48 +04001{{/*
2Service account to merge into the libcoder template
3*/}}
4{{- define "coder.serviceaccount" -}}
5{{- end -}}
6
7{{/*
8Deployment to merge into the libcoder template
9*/}}
10{{- define "coder.deployment" -}}
11spec:
12 template:
13 spec:
14 containers:
15 -
16{{ include "libcoder.containerspec" (list . "coder.containerspec") | indent 8}}
17
18{{- end -}}
19
20{{/*
21ContainerSpec for the Coder container of the Coder deployment
22*/}}
23{{- define "coder.containerspec" -}}
24args:
25{{- if .Values.coder.commandArgs }}
26 {{- toYaml .Values.coder.commandArgs | nindent 12 }}
27{{- else }}
28 {{- if .Values.coder.workspaceProxy }}
29- wsproxy
30 {{- end }}
31- server
32{{- end }}
33{{- if .Values.coder.envFrom }}
34envFrom:
35{{- with .Values.coder.envFrom }}
36{{ toYaml . }}
37{{- end }}
38{{- end }}
39env:
40- name: CODER_HTTP_ADDRESS
41 value: "0.0.0.0:8080"
42- name: CODER_PROMETHEUS_ADDRESS
43 value: "0.0.0.0:2112"
44{{- if .Values.provisionerDaemon.pskSecretName }}
45- name: CODER_PROVISIONER_DAEMON_PSK
46 valueFrom:
47 secretKeyRef:
48 name: {{ .Values.provisionerDaemon.pskSecretName | quote }}
49 key: psk
50{{- end }}
51 # Set the default access URL so a `helm apply` works by default.
52 # See: https://github.com/coder/coder/issues/5024
53{{- $hasAccessURL := false }}
54{{- range .Values.coder.env }}
55{{- if eq .name "CODER_ACCESS_URL" }}
56{{- $hasAccessURL = true }}
57{{- end }}
58{{- end }}
59{{- if and (not $hasAccessURL) .Values.coder.envUseClusterAccessURL }}
60- name: CODER_ACCESS_URL
61 value: {{ include "coder.defaultAccessURL" . | quote }}
62{{- end }}
63# Used for inter-pod communication with high-availability.
64- name: KUBE_POD_IP
65 valueFrom:
66 fieldRef:
67 fieldPath: status.podIP
68- name: CODER_DERP_SERVER_RELAY_URL
69 value: "http://$(KUBE_POD_IP):8080"
70{{- include "coder.tlsEnv" . }}
71{{- with .Values.coder.env }}
72{{ toYaml . }}
73{{- end }}
74ports:
75- name: "http"
76 containerPort: 8080
77 protocol: TCP
78 {{- if eq (include "coder.tlsEnabled" .) "true" }}
79- name: "https"
80 containerPort: 8443
81 protocol: TCP
82 {{- end }}
83 {{- range .Values.coder.env }}
84 {{- if eq .name "CODER_PROMETHEUS_ENABLE" }}
85 {{/*
86 This sadly has to be nested to avoid evaluating the second part
87 of the condition too early and potentially getting type errors if
88 the value is not a string (like a `valueFrom`). We do not support
89 `valueFrom` for this env var specifically.
90 */}}
91 {{- if eq .value "true" }}
92- name: "prometheus-http"
93 containerPort: 2112
94 protocol: TCP
95 {{- end }}
96 {{- end }}
97 {{- end }}
98readinessProbe:
99 httpGet:
100 path: /healthz
101 port: "http"
102 scheme: "HTTP"
103livenessProbe:
104 httpGet:
105 path: /healthz
106 port: "http"
107 scheme: "HTTP"
108{{- end }}