Skip to content

Commit bec7eb9

Browse files
committed
Fix prettier, linting, docs
Signed-off-by: Spike Curtis <spike@coder.com>
1 parent c8bbf18 commit bec7eb9

File tree

13 files changed

+209
-178
lines changed

13 files changed

+209
-178
lines changed

.prettierignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ scaletest/terraform/secrets.tfvars
6767
# .prettierignore.include:
6868
# Helm templates contain variables that are invalid YAML and can't be formatted
6969
# by Prettier.
70-
helm/templates/*.yaml
70+
helm/**/templates/*.yaml
7171

7272
# Terraform state files used in tests, these are automatically generated.
7373
# Example: provisioner/terraform/testdata/instance-id/instance-id.tfstate.json

.prettierignore.include

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Helm templates contain variables that are invalid YAML and can't be formatted
22
# by Prettier.
3-
helm/templates/*.yaml
3+
helm/**/templates/*.yaml
44

55
# Terraform state files used in tests, these are automatically generated.
66
# Example: provisioner/terraform/testdata/instance-id/instance-id.tfstate.json

docs/admin/configure.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ If you are providing TLS certificates directly to the Coder server, either
4242

4343
1. Use a single certificate and key for both the root and wildcard domains.
4444
2. Configure multiple certificates and keys via
45-
[`coder.tls.secretNames`](https://github.com/coder/coder/blob/main/helm/values.yaml) in the Helm Chart, or
45+
[`coder.tls.secretNames`](https://github.com/coder/coder/blob/main/helm/coder/values.yaml) in the Helm Chart, or
4646
[`--tls-cert-file`](../cli/server.md#--tls-cert-file) and [`--tls-key-file`](../cli/server.md#--tls-key-file) command
4747
line options (these both take a comma separated list of files; list certificates and their respective keys in the
4848
same order).

docs/admin/scale.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Users accessing workspaces via SSH will consume fewer resources, as SSH connecti
4242

4343
Workspace builds are CPU-intensive, as it relies on Terraform. Various [Terraform providers](https://registry.terraform.io/browse/providers) have different resource requirements.
4444
When tested with our [kubernetes](https://github.com/coder/coder/tree/main/examples/templates/kubernetes) template, `coderd` will consume roughly 0.25 cores per concurrent workspace build.
45-
For effective provisioning, our helm chart prefers to schedule [one coderd replica per-node](https://github.com/coder/coder/blob/main/helm/values.yaml#L110-L121).
45+
For effective provisioning, our helm chart prefers to schedule [one coderd replica per-node](https://github.com/coder/coder/blob/main/helm/coder/values.yaml#L110-L121).
4646

4747
We recommend:
4848

docs/install/kubernetes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ to log in and manage templates.
109109
> You can view our
110110
> [Helm README](https://github.com/coder/coder/blob/main/helm#readme) for
111111
> details on the values that are available, or you can view the
112-
> [values.yaml](https://github.com/coder/coder/blob/main/helm/values.yaml)
112+
> [values.yaml](https://github.com/coder/coder/blob/main/helm/coder/values.yaml)
113113
> file directly.
114114
115115
If you are deploying Coder on AWS EKS and service is set to `LoadBalancer`, AWS will default to the Classic load balancer. The load balancer external IP will be stuck in a pending status unless sessionAffinity is set to None.

helm/Makefile

+9-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ all: lint
1313
lint: lint/helm
1414
.PHONY: lint
1515

16-
lint/helm:
17-
helm lint --strict --set coder.image.tag=v0.0.1 .
16+
lint/helm: lint/helm/coder lint/helm/provisioner
1817
.PHONY: lint/helm
18+
19+
lint/helm/coder:
20+
helm lint --strict --set coder.image.tag=v0.0.1 coder/
21+
.PHONY: lint/helm/coder
22+
23+
lint/helm/provisioner:
24+
helm lint --strict --set coder.image.tag=v0.0.1 provisioner/
25+
.PHONY: lint/helm/provisioner

helm/coder/templates/_coder.tpl

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

helm/coder/templates/coder.yaml

+2-94
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,5 @@
11
---
2-
{{- include "libcoder.serviceaccount" (list . "coder.serviceaccount") -}}
3-
{{- define "coder.serviceaccount" -}}
4-
{{- end }}
2+
{{ include "libcoder.serviceaccount" (list . "coder.serviceaccount") }}
53

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

helm/provisioner/templates/_coder.tpl

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{{/*
2+
Service account to merge into the libcoder template
3+
*/}}
4+
{{- define "coder.serviceaccount" -}}
5+
{{- end }}
6+
7+
{{/*
8+
Deployment to merge into the libcoder template
9+
*/}}
10+
{{- define "coder.deployment" -}}
11+
spec:
12+
template:
13+
spec:
14+
containers:
15+
-
16+
{{ include "libcoder.containerspec" (list . "coder.containerspec") | indent 8}}
17+
18+
{{- end }}
19+
20+
{{/*
21+
ContainerSpec for the Coder container of the Coder deployment
22+
*/}}
23+
{{- define "coder.containerspec" -}}
24+
args:
25+
{{- if .Values.coder.commandArgs }}
26+
{{- toYaml .Values.coder.commandArgs | nindent 12 }}
27+
{{- else }}
28+
- provisionerd
29+
- start
30+
{{- end }}
31+
env:
32+
- name: CODER_PROMETHEUS_ADDRESS
33+
value: "0.0.0.0:2112"
34+
- name: CODER_PROVISIONER_DAEMON_PSK
35+
valueFrom:
36+
secretKeyRef:
37+
name: {{ .Values.provisionerDaemon.pskSecretName | quote }}
38+
key: psk
39+
{{- if include "provisioner.tags" . }}
40+
- name: CODER_PROVISIONERD_TAGS
41+
value: {{ include "provisioner.tags" . }}
42+
{{- end }}
43+
# Set the default access URL so a `helm apply` works by default.
44+
# See: https://github.com/coder/coder/issues/5024
45+
{{- $hasAccessURL := false }}
46+
{{- range .Values.coder.env }}
47+
{{- if eq .name "CODER_URL" }}
48+
{{- $hasAccessURL = true }}
49+
{{- end }}
50+
{{- end }}
51+
{{- if not $hasAccessURL }}
52+
- name: CODER_URL
53+
value: {{ include "coder.defaultAccessURL" . | quote }}
54+
{{- end }}
55+
{{- with .Values.coder.env }}
56+
{{ toYaml . }}
57+
{{- end }}
58+
ports:
59+
{{- range .Values.coder.env }}
60+
{{- if eq .name "CODER_PROMETHEUS_ENABLE" }}
61+
{{/*
62+
This sadly has to be nested to avoid evaluating the second part
63+
of the condition too early and potentially getting type errors if
64+
the value is not a string (like a `valueFrom`). We do not support
65+
`valueFrom` for this env var specifically.
66+
*/}}
67+
{{- if eq .value "true" }}
68+
- name: "prometheus-http"
69+
containerPort: 2112
70+
protocol: TCP
71+
{{- end }}
72+
{{- end }}
73+
{{- end }}
74+
{{- end }}
75+
76+
{{/*
77+
Convert provisioner tags to the environment variable format
78+
*/}}
79+
{{- define "provisioner.tags" -}}
80+
{{- $keys := keys .Values.provisionerDaemon.tags | sortAlpha -}}
81+
{{- range $i, $key := $keys -}}
82+
{{- $val := get $.Values.provisionerDaemon.tags $key -}}
83+
{{- if ne $i 0 -}},{{- end -}}{{ $key }}={{ $val }}
84+
{{- end -}}
85+
{{- end -}}

0 commit comments

Comments
 (0)