Files
coder/helm/provisioner

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.coderServer defaults to the Coder chart's pods in any namespace. Override to and ports if CODER_URL points elsewhere, such as an external address. An empty to allows any destination on those ports.
  • egress.kubernetesAPI defaults to any destination on ports 443 and 6443, because control plane addresses vary by cluster. That includes the internet and an external CODER_URL, so if you set to to your API server, allow those through coderServer or extraEgress.
  • egress.dns.ports defaults to 53; use 5353 on OpenShift. Setting any built-in ports list 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 deployment
  • serviceAccount.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=true to disable service account creation,
  • Set coder.serviceAccount.workspacePerms=false to disable creation of a role and role binding,
  • Set coder.serviceAccount.nameOverride to 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 .yaml file in testdata/ along with a corresponding .golden file, if required.
  • Add the test case to the array in chart_test.go, setting name to the name of the files you added previously (without the extension). If appropriate, set expectedError.
  • Run the tests and ensure that no regressions in existing test cases occur: go test ./tests.