Skip to content

Commit 41c4b31

Browse files
authored
feat: helm: support adding affinity rule for coderd service (#157)
This commit adds the `coderd.affinity` configuration knob. This allows the user to specify any affinity they like for the coderd deployment. An example affinity is provided.
1 parent 61c230c commit 41c4b31

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ View [our docs](https://coder.com/docs/setup/installation) for detailed installa
2525
| certs | object | Certificate that will be mounted inside Coder services. | `{"secret":{"key":"","name":""}}` |
2626
| certs.secret.key | string | Key pointing to a certificate in the secret. | `""` |
2727
| certs.secret.name | string | Name of the secret. | `""` |
28-
| coderd | object | Primary service responsible for all things Coder! | `{"builtinProviderServiceAccount":{"annotations":{},"labels":{}},"devurlsHost":"","image":"","oidc":{"enableRefresh":false,"redirectOptions":{}},"podSecurityContext":{"runAsNonRoot":true,"runAsUser":1000,"seccompProfile":{"type":"RuntimeDefault"}},"replicas":1,"resources":{"limits":{"cpu":"250m","memory":"512Mi"},"requests":{"cpu":"250m","memory":"512Mi"}},"satellite":{"accessURL":"","enable":false,"primaryURL":""},"securityContext":{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"seccompProfile":{"type":"RuntimeDefault"}},"serviceAnnotations":{},"serviceNodePorts":{"http":null,"https":null},"serviceSpec":{"externalTrafficPolicy":"Local","loadBalancerIP":"","loadBalancerSourceRanges":[],"type":"LoadBalancer"},"superAdmin":{"passwordSecret":{"key":"password","name":""}},"tls":{"devurlsHostSecretName":"","hostSecretName":""},"trustProxyIP":false}` |
28+
| coderd | object | Primary service responsible for all things Coder! | `{"affinity":{},"builtinProviderServiceAccount":{"annotations":{},"labels":{}},"devurlsHost":"","image":"","oidc":{"enableRefresh":false,"redirectOptions":{}},"podSecurityContext":{"runAsNonRoot":true,"runAsUser":1000,"seccompProfile":{"type":"RuntimeDefault"}},"replicas":1,"resources":{"limits":{"cpu":"250m","memory":"512Mi"},"requests":{"cpu":"250m","memory":"512Mi"}},"satellite":{"accessURL":"","enable":false,"primaryURL":""},"securityContext":{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"seccompProfile":{"type":"RuntimeDefault"}},"serviceAnnotations":{},"serviceNodePorts":{"http":null,"https":null},"serviceSpec":{"externalTrafficPolicy":"Local","loadBalancerIP":"","loadBalancerSourceRanges":[],"type":"LoadBalancer"},"superAdmin":{"passwordSecret":{"key":"password","name":""}},"tls":{"devurlsHostSecretName":"","hostSecretName":""},"trustProxyIP":false}` |
29+
| coderd.affinity | object | Allows specifying an affinity rule for the `coderd` deployment. If you set `coderd.replicas` to a value higher than 1, you may wish to also add a pod anti-affinity definition to ensure that multiple coderd pods are not scheduled on the same node. | `{}` |
2930
| coderd.builtinProviderServiceAccount | object | Customize the built-in Kubernetes provider service account. | `{"annotations":{},"labels":{}}` |
3031
| coderd.builtinProviderServiceAccount.annotations | object | A KV mapping of annotations. See: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ | `{}` |
3132
| coderd.builtinProviderServiceAccount.labels | object | Add labels to the service account used for the built-in provider. | `{}` |

templates/_functions.tpl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,16 @@ resources:
2525
{{- end }}
2626
{{- end }}
2727
{{- end }}
28+
29+
{{/*
30+
coder.template.render -- renders a value that contains template.
31+
Usage:
32+
{{ include "coder.template.render" ( dict "value" .Values.path.to.the.Value "context" $) }}
33+
*/}}
34+
{{- define "coder.template.render" -}}
35+
{{- if typeIs "string" .value }}
36+
{{- tpl .value .context }}
37+
{{- else }}
38+
{{- tpl (.value | toYaml) .context }}
39+
{{- end }}
40+
{{- end -}}

templates/coderd.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ spec:
4747
{{- if not .Values.coderd.satellite.enable }}
4848
serviceAccountName: coder
4949
{{- end }}
50+
{{- if .Values.coderd.affinity }}
51+
affinity: {{- include "coder.template.render" ( dict "value" .Values.coderd.affinity "context" $) | nindent 8 }}
52+
{{- end }}
5053
{{- include "coder.services.nodeSelector" . | indent 6 }}
5154
{{- include "coder.serviceTolerations" . | indent 6 }}
5255
{{- if not .Values.coderd.satellite.enable }}

values.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,27 @@ coderd:
151151
# contains the super admin password.
152152
key: "password"
153153

154+
# coderd.affinity -- Allows specifying an affinity rule for the `coderd`
155+
# deployment. If you set `coderd.replicas` to a value higher than 1, you
156+
# may wish to also add a pod anti-affinity definition to ensure that
157+
# multiple coderd pods are not scheduled on the same node.
158+
affinity: {}
159+
# Example:
160+
# ```
161+
# affinity:
162+
# podAntiAffinity:
163+
# preferredDuringSchedulingIgnoredDuringExecution:
164+
# - podAffinityTerm:
165+
# labelSelector:
166+
# matchExpressions:
167+
# - key: app
168+
# operator: In
169+
# values:
170+
# - "coderd"
171+
# topologyKey: kubernetes.io/hostname
172+
# weight: 1
173+
# ```
174+
154175
# envbox -- Required for running Docker inside containers. See requirements:
155176
# https://coder.com/docs/coder/v1.19/admin/workspace-management/cvms
156177
envbox:

0 commit comments

Comments
 (0)