Coder Helm Chart
This directory contains the Helm chart used to deploy Coder provisioner daemons onto a Kubernetes cluster.
External provisioner daemons are a Premium feature. Contact sales@coder.com.
Getting Started
Warning
: The main branch in this repository does not represent the latest release of Coder. Please reference our installation docs for instructions on a tagged release.
View our docs for detailed installation instructions.
Values
Please refer to values.yaml for available Helm values and their defaults.
A good starting point for your values file is:
coder:
env:
- name: CODER_URL
value: "https://coder.example.com"
# Enable the Prometheus metrics endpoint.
- name: CODER_PROMETHEUS_ENABLE
value: "true"
replicaCount: 10
provisionerDaemon:
keySecretName: "coder-provisionerd-key"
keySecretKey: "provisionerd-key"
Specific Examples
Below are some common specific use-cases when deploying a Coder provisioner.
Set Labels and Annotations
If you need to set deployment- or pod-level labels and annotations, set coder.{annotations,labels} or coder.{podAnnotations,podLabels}.
Example:
coder:
# ...
annotations:
com.coder/annotation/foo: bar
com.coder/annotation/baz: qux
labels:
com.coder/label/foo: bar
com.coder/label/baz: qux
podAnnotations:
com.coder/podAnnotation/foo: bar
com.coder/podAnnotation/baz: qux
podLabels:
com.coder/podLabel/foo: bar
com.coder/podLabel/baz: qux
Network Policy
Set coder.networkPolicy.enable to create a NetworkPolicy for the provisioner
pods. Your CNI must enforce NetworkPolicy for it to have any effect.
The provisioner only makes outbound connections, so ingress is limited to
Prometheus metrics when CODER_PROMETHEUS_ENABLE is true in coder.env, with no
extra toggle. The chart does not detect CODER_PROMETHEUS_ENABLE set through
valueFrom, so set it as a literal value in coder.env; otherwise the port is
never added to the NetworkPolicy and scrapes are blocked. Restrict who can scrape with coder.networkPolicy.prometheus.from,
or allow more with coder.networkPolicy.extraIngress.
Egress is restricted by default. Only DNS, the Coder server, and the Kubernetes
API ports are allowed, plus anything in coder.networkPolicy.extraEgress. Set
coder.networkPolicy.egress.enable to false to leave egress open.
egress.coderServerdefaults to the Coder chart's pods in any namespace. OverridetoandportsifCODER_URLpoints elsewhere, such as an external address. An emptytoallows any destination on those ports.egress.kubernetesAPIdefaults to any destination on ports 443 and 6443, because control plane addresses vary by cluster. That includes the internet and an externalCODER_URL, so if you settoto your API server, allow those throughcoderServerorextraEgress.egress.dns.portsdefaults to 53; use 5353 on OpenShift. Setting any built-inportslist to[]removes that rule.
Your templates probably reach other services during builds, such as cloud APIs
and registries. Allow them with extraEgress. This example opens HTTPS to any destination;
narrow cidr to the ranges you need:
coder:
networkPolicy:
enable: true
extraEgress:
- to:
- ipBlock:
cidr: 0.0.0.0/0
ports:
- port: 443
protocol: TCP
Additional Templates
You can include extra Kubernetes manifests in extraTemplates.
The below example will also create a ConfigMap along with the Helm release:
coder:
# ...
provisionerDaemon:
# ...
extraTemplates:
- |
apiVersion: v1
kind: ConfigMap
metadata:
name: some-config
namespace: {{ .Release.Namespace }}
data:
key: some-value
Disable Service Account Creation
Deploying multiple provisioners in the same namespace
To deploy multiple provisioners in the same namespace, set the following values explicitly to avoid conflicts:
nameOverride: controls the name of the provisioner deploymentserviceAccount.name: controls the name of the service account.
Note that nameOverride does not apply to extraTemplates, as illustrated below:
coder:
# ...
serviceAccount:
name: other-coder-provisioner
provisionerDaemon:
# ...
nameOverride: "other-coder-provisioner"
extraTemplates:
- |
apiVersion: v1
kind: ConfigMap
metadata:
name: some-other-config
namespace: {{ .Release.Namespace }}
data:
key: some-other-value
If you wish to deploy a second provisioner that references an existing service account, you can do so as follows:
- Set
coder.serviceAccount.disableCreate=trueto disable service account creation, - Set
coder.serviceAccount.workspacePerms=falseto disable creation of a role and role binding, - Set
coder.serviceAccount.nameOverrideto the name of an existing service account.
See below for a concrete example:
coder:
# ...
serviceAccount:
name: preexisting-service-account
disableCreate: true
workspacePerms: false
provisionerDaemon:
# ...
nameOverride: "other-coder-provisioner"
Testing
The test suite for this chart lives in ./tests/chart_test.go.
Each test case runs helm template against the corresponding test_case.yaml, and compares the output with that of the corresponding test_case.golden in ./tests/testdata.
If expectedError is not empty for that specific test case, no corresponding .golden file is required.
To add a new test case:
- Create an appropriately named
.yamlfile intestdata/along with a corresponding.goldenfile, if required. - Add the test case to the array in
chart_test.go, settingnameto the name of the files you added previously (without the extension). If appropriate, setexpectedError. - Run the tests and ensure that no regressions in existing test cases occur:
go test ./tests.