Benjamin Peinhardt 05124309ee
feat: add templates and update icon paths (#144)
This PR copies the templates in coder/coder/examples/templates over to
the registry, so that template contribution can be done through the
registry.
For now, the starter templates in the coder/coder binary and the
templates available in coder/registry will simply be different
constructs, until we find a solution we like around a single source of
truth for templates that doesn't raise hairy semver concerns for
coder/coder:
https://codercom.slack.com/archives/C05T7165ET1/p1749493368773469
2025-06-12 13:06:46 -05:00

3.2 KiB

display_name description icon maintainer_github verified tags
Kubernetes (Devcontainer) Provision envbuilder pods as Coder workspaces ../../../../.icons/k8s.png coder true
container
kubernetes
devcontainer

Remote Development on Kubernetes Pods (with Devcontainers)

Provision Devcontainers as Coder workspaces on Kubernetes with this example template.

Prerequisites

Infrastructure

Cluster: This template requires an existing Kubernetes cluster.

Container Image: This template uses the envbuilder image to build a Devcontainer from a devcontainer.json.

(Optional) Cache Registry: Envbuilder can utilize a Docker registry as a cache to speed up workspace builds. The envbuilder Terraform provider will check the contents of the cache to determine if a prebuilt image exists. In the case of some missing layers in the registry (partial cache miss), Envbuilder can still utilize some of the build cache from the registry.

Authentication

This template authenticates using a ~/.kube/config, if present on the server, or via built-in authentication if the Coder provisioner is running on Kubernetes with an authorized ServiceAccount. To use another authentication method, edit the template.

Architecture

Coder supports devcontainers with envbuilder, an open source project. Read more about this in Coder's documentation.

This template provisions the following resources:

  • Kubernetes deployment (ephemeral)
  • Kubernetes persistent volume claim (persistent on /workspaces)
  • Envbuilder cached image (optional, persistent).

This template will fetch a Git repo containing a devcontainer.json specified by the repo parameter, and builds it with envbuilder. The Git repository is cloned inside the /workspaces volume if not present. Any local changes to the Devcontainer files inside the volume will be applied when you restart the workspace. As you might suspect, any tools or files outside of /workspaces or not added as part of the Devcontainer specification are not persisted. Edit the devcontainer.json instead!

Note

This template is designed to be a starting point! Edit the Terraform to extend the template to support your use case.

Caching

To speed up your builds, you can use a container registry as a cache. When creating the template, set the parameter cache_repo.

See the Envbuilder Terraform Provider Examples for a more complete example of how the provider works.

Note

We recommend using a registry cache with authentication enabled. To allow Envbuilder to authenticate with the registry cache, specify the variable cache_repo_dockerconfig_secret with the name of a Kubernetes secret in the same namespace as Coder. The secret must contain the key .dockerconfigjson.