feat: add rootless Podman starter template and EKS Auto Mode guidance (#30804)
## Summary
- EKS Auto Mode supports kernel sysctls via the NodeClass
`advancedCompute` field since 2026-10-01 ([AWS
announcement](https://aws.amazon.com/about-aws/whats-new/2026/10/eks-auto-mode-advanced-compute-config/)),
so rootless Podman no longer requires a separate managed node group;
document the custom NodeClass recipe and the `idsPerPod` requirement for
`hostUsers: false` pods
- Document native overlay storage (real-filesystem graph root + clearing
the image's `mount_program` pin), which removes the `/dev/fuse` device
plugin dependency on kernel 5.13+
- Add a "Nested container engines" section: one level of nesting is
supported; the dev container `docker-in-docker` feature is not, with
`docker-outside-of-docker` as the documented alternative
- Add the `kubernetes-podman-rootless` starter template (`coder
templates init --id kubernetes-podman-rootless`):
- persistent `/home/coder` volume (`fs_group_change_policy =
"OnRootMismatch"`), so repos, images and build cache survive restarts
- startup script fails with the Podman log when the API socket doesn't
start
- `kubernetes_pod_v1`, pinned to amd64 (the image is amd64-only)
Refs DOCS-1277. Related follow-up: DOG-74.
## Testing
- 2026-10-14, EKS Auto Mode v1.37 sandbox: rootless Podman on pure Auto
Mode nodes with native overlay, including builds with cache mounts,
Testcontainers-style Postgres, and the Docker-compatible API socket
- 2026-11-02, same cluster, starter template at 0227e04 on a 20 GiB gp3
home volume:
- ext4 home, `overlay` driver with native overlay diff, graph root on
the volume
- `podman run`, classic `docker build` via the agent's `DOCKER_HOST`,
Docker API socket
- after stop/start: home files, all images, and subuid-owned layer files
(`101233:101233` on disk, `1234:1234` in the container) intact; built
image runs without a rebuild
- Fail-fast startup path tested with a stub `podman` only (exit 1,
prints the `newuidmap` error)
- `terraform validate` (no deprecation warnings), markdownlint, CI `gen`
and `lint-docs`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Nick Vigilante <nickvigilante@users.noreply.github.com>
This commit is contained in:
7 files changed
+316
-11
No files matched your search
+1
-1
@@ -6,7 +6,7 @@ USAGE:
|
||||
Get started with a templated template.
|
||||
|
||||
OPTIONS:
|
||||
--id aws-devcontainer|aws-linux|aws-windows|azure-linux|digitalocean-linux|docker|docker-devcontainer|docker-envbuilder|gcp-devcontainer|gcp-linux|gcp-vm-container|gcp-windows|incus|kubernetes|kubernetes-devcontainer|nomad-docker|quickstart|scratch
|
||||
--id aws-devcontainer|aws-linux|aws-windows|azure-linux|digitalocean-linux|docker|docker-devcontainer|docker-envbuilder|gcp-devcontainer|gcp-linux|gcp-vm-container|gcp-windows|incus|kubernetes|kubernetes-devcontainer|kubernetes-podman-rootless|nomad-docker|quickstart|scratch
|
||||
Specify a given example template by ID.
|
||||
|
||||
———
|
||||
|
||||
@@ -8,7 +8,7 @@ There are a few ways to run Docker within container-based Coder workspaces.
|
||||
|------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| [Sysbox container runtime](#sysbox-container-runtime) | Install the Sysbox runtime on your Kubernetes nodes or Docker host(s) for secure docker-in-docker and systemd-in-docker. Works with Google Kubernetes Engine (GKE), Amazon Elastic Kubernetes Service (EKS), Azure Kubernetes Service (AKS), Docker. | Requires [compatible nodes](https://github.com/nestybox/sysbox#host-requirements). [Limitations](https://github.com/nestybox/sysbox/blob/master/docs/user-guide/limitations.md) |
|
||||
| [Envbox](#envbox) | A container image with all the packages necessary to run an inner Sysbox container. Removes the need to setup sysbox-runc on your nodes. Works with GKE, EKS, AKS. | Requires running the outer container as privileged (the inner container that acts as the workspace is locked down). Requires compatible [nodes](https://github.com/nestybox/sysbox/blob/master/docs/distro-compat.md#sysbox-distro-compatibility). |
|
||||
| [Rootless Podman](#rootless-podman) | Run Podman inside Coder workspaces. Does not require a custom runtime or privileged containers. Works with GKE, EKS, AKS, Rancher Kubernetes Engine (RKE), OpenShift | Requires smarter-device-manager for Filesystem in Userspace (FUSE) mounts. [See all](https://github.com/containers/podman/blob/main/rootless.md#shortcomings-of-rootless-podman) |
|
||||
| [Rootless Podman](#rootless-podman) | Run Podman inside Coder workspaces. Does not require a custom runtime or privileged containers. Works with GKE, EKS, AKS, Rancher Kubernetes Engine (RKE), OpenShift | Requires a Filesystem in Userspace (FUSE) device plugin, or native overlay storage on kernel 5.13 or later. [See all](https://github.com/containers/podman/blob/main/rootless.md#shortcomings-of-rootless-podman) |
|
||||
| [Privileged docker sidecar](#privileged-sidecar-container) | Run Docker as a privileged sidecar container. | Requires a privileged container. Workspaces can break out to root on the host machine. |
|
||||
|
||||
## Sysbox container runtime
|
||||
@@ -129,7 +129,7 @@ Some drawbacks include:
|
||||
Once the image is cached in `envbox`, startup performance is similar.
|
||||
|
||||
Envbox requires the same kernel requirements as running sysbox directly on the nodes.
|
||||
Refer to sysbox's [compatibility matrix](https://github.com/nestybox/sysbox/blob/master/docs/distro-compat.md#sysbox-distro-compatibility) to ensure your nodes are compliant.
|
||||
Refer to sysbox's [compatibility matrix](https://github.com/nestybox/sysbox/blob/master/docs/distro-compat.md#sysbox-distro-compatibility) to make sure your nodes are compliant.
|
||||
|
||||
To get started with `envbox`, refer to the [starter template](../../../../examples/templates/kubernetes-envbox) or visit the [repo](https://github.com/coder/envbox).
|
||||
|
||||
@@ -222,7 +222,7 @@ Before using Podman, review the following documentation:
|
||||
```
|
||||
|
||||
> ⚠️ **Warning**: If you are using a managed Kubernetes distribution (for example, AKS, EKS, GKE), be sure to set node labels via your cloud provider.
|
||||
> Otherwise, your nodes may drop the labels and break podman functionality.
|
||||
> Otherwise, your nodes might drop the labels and break podman functionality.
|
||||
|
||||
3. For systems running SELinux, you might need to disable SELinux or set it to permissive mode.
|
||||
|
||||
@@ -330,16 +330,113 @@ spec:
|
||||
### Rootless Podman on EKS Auto Mode
|
||||
|
||||
The `EC2NodeClass` above applies to self-managed Karpenter nodes.
|
||||
On EKS Auto Mode, the built-in `NodeClass` (`eks.amazonaws.com`) doesn't expose `userData` or kernel sysctls, so `user.max_user_namespaces` stays at `0` with no way to raise it on those nodes.
|
||||
Run Podman workspaces on a separate managed node group instead.
|
||||
On EKS Auto Mode, raise `user.max_user_namespaces` with the `advancedCompute` field on a custom `NodeClass` (`eks.amazonaws.com`).
|
||||
Auto Mode `NodeClass` resources [support `advancedCompute`](https://aws.amazon.com/about-aws/whats-new/2026/10/eks-auto-mode-advanced-compute-config/), so this works on pure Auto Mode nodes with no managed node group.
|
||||
|
||||
```yaml
|
||||
apiVersion: eks.amazonaws.com/v1
|
||||
kind: NodeClass
|
||||
metadata:
|
||||
name: podman
|
||||
spec:
|
||||
# Reuse the Auto Mode node role so the EKS access entry already exists.
|
||||
role: <your Auto Mode node role>
|
||||
subnetSelectorTerms:
|
||||
- id: <subnet ID 1>
|
||||
- id: <subnet ID 2>
|
||||
securityGroupSelectorTerms:
|
||||
- id: <cluster security group ID>
|
||||
advancedCompute:
|
||||
kernel:
|
||||
sysctl:
|
||||
user.max_user_namespaces: 65536
|
||||
```
|
||||
|
||||
Reference the `NodeClass` from a `NodePool` and schedule Podman workspaces onto that pool with a node selector.
|
||||
Refer to [Create a Node Class for Amazon EKS](https://docs.aws.amazon.com/eks/latest/userguide/create-node-class.html) for the full `advancedCompute` reference.
|
||||
|
||||
If you can't use `advancedCompute`, run Podman workspaces on a managed node group instead.
|
||||
The default Amazon Linux 2023 (AL2023) Amazon Machine Images (AMIs) ship with user namespaces enabled.
|
||||
|
||||
> On a brand-new Auto Mode cluster, install the `vpc-cni` and `kube-proxy` add-ons before your managed node group can reach `Ready`.
|
||||
Pods that set `hostUsers: false` also need `advancedCompute.kubelet.idsPerPod` raised above the 65536 default before rootless Podman can allocate subordinate ID ranges inside them.
|
||||
The value must be a multiple of 65536, and `idsPerPod` requires `user.max_user_namespaces` to be set on the same `NodeClass`:
|
||||
|
||||
```yaml
|
||||
advancedCompute:
|
||||
kernel:
|
||||
sysctl:
|
||||
user.max_user_namespaces: 65536
|
||||
kubelet:
|
||||
idsPerPod: 1048576
|
||||
```
|
||||
|
||||
### Use native overlay storage instead of fuse-overlayfs
|
||||
|
||||
Kernel overlayfs cannot stack on the workspace container's own overlay root filesystem.
|
||||
Without extra configuration, Podman falls back to `fuse-overlayfs`, which requires the `/dev/fuse` device and the smarter-device-manager setup above.
|
||||
On nodes with kernel 5.13 or later, you can skip the FUSE device entirely:
|
||||
|
||||
1. Put the Podman graph root on a real filesystem such as ext4 or xfs.
|
||||
If your template mounts a persistent volume at `/home/coder`, like the `kubernetes` starter, the default graph root already qualifies and keeps images across workspace restarts.
|
||||
For ephemeral workspaces, mount an `emptyDir` volume at `/home/coder/.local/share/containers` instead; pulled images and build cache are lost when the workspace stops.
|
||||
1. Clear the `mount_program` setting, because some Podman images pin it to `fuse-overlayfs` in `/etc/containers/storage.conf`.
|
||||
Write the override from the agent `startup_script`, which can also start the Docker-compatible API socket:
|
||||
|
||||
```tf
|
||||
startup_script = <<-EOT
|
||||
mkdir -p ~/.config/containers
|
||||
printf '[storage]\ndriver = "overlay"\n\n[storage.options.overlay]\nmount_program = ""\n' > ~/.config/containers/storage.conf
|
||||
(podman system service --time=0 unix:///tmp/podman.sock >/tmp/podman-service.log 2>&1 &)
|
||||
for i in $(seq 50); do [ -S /tmp/podman.sock ] && break; sleep 0.1; done
|
||||
if [ ! -S /tmp/podman.sock ]; then
|
||||
echo "Podman API socket didn't start:" >&2
|
||||
cat /tmp/podman-service.log >&2
|
||||
exit 1
|
||||
fi
|
||||
EOT
|
||||
```
|
||||
|
||||
Set `DOCKER_HOST=unix:///tmp/podman.sock` for Docker clients that expect a daemon socket.
|
||||
Also set `DOCKER_BUILDKIT=0` so that `docker build` and `docker compose build` use the classic builder, because BuildKit can't start inside the workspace.
|
||||
`docker buildx` commands still require BuildKit and aren't supported.
|
||||
|
||||
With both settings, Podman uses native kernel overlay, which performs better than `fuse-overlayfs` and removes the device plugin dependency.
|
||||
When you use native overlay, skip the smarter-device-manager steps above and remove the `github.com/fuse` limit from the pod spec; without the device plugin, that limit keeps pods in `Pending`.
|
||||
|
||||
For a complete reference template, run `coder templates init --id kubernetes-podman-rootless` or refer to [`examples/templates/kubernetes-podman-rootless`](https://github.com/coder/coder/tree/main/examples/templates/kubernetes-podman-rootless).
|
||||
|
||||
### Nested container engines
|
||||
|
||||
Rootless Podman supports one level of nesting: the workspace runs containers, builds images, and serves the Docker-compatible API socket.
|
||||
Running another container engine inside a container that the workspace engine started is not supported.
|
||||
This includes the dev container [`docker-in-docker` feature](https://github.com/devcontainers/features/tree/main/src/docker-in-docker), which starts a nested daemon inside the dev container.
|
||||
|
||||
Use the [`docker-outside-of-docker` feature](https://github.com/devcontainers/features/tree/main/src/docker-outside-of-docker) instead.
|
||||
The dev container drives the workspace engine through its socket, so containers run as siblings of the dev container instead of nested inside it.
|
||||
Keep the repository path identical inside the dev container and the workspace, for example with `workspaceMount`, so bind mounts resolve against the engine correctly.
|
||||
|
||||
The feature mounts the workspace's `/var/run/docker.sock` by default, which doesn't exist with rootless Podman.
|
||||
Start the API socket from the agent `startup_script` as shown in [Use native overlay storage](#use-native-overlay-storage-instead-of-fuse-overlayfs), then override the mount in `devcontainer.json` to point at it:
|
||||
|
||||
```json
|
||||
"mounts": [
|
||||
{
|
||||
"source": "/tmp/podman.sock",
|
||||
"target": "/var/run/docker-host.sock",
|
||||
"type": "bind"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Building dev container features, such as `docker-outside-of-docker`, fails against rootless Podman because the dev container CLI builds them with BuildKit, which can't start inside the workspace.
|
||||
Run `devcontainer up --buildkit never` with `DOCKER_BUILDKIT=0` set to use the classic builder instead.
|
||||
Coder's [dev container integration](../../integrations/devcontainers/index.md) doesn't pass this flag, so it doesn't support rootless Podman workspaces yet.
|
||||
To run dev containers on Kubernetes without a container engine in the workspace, use [Envbuilder](../../integrations/devcontainers/envbuilder/index.md) instead.
|
||||
|
||||
## Privileged sidecar container
|
||||
|
||||
A [privileged container](https://docs.docker.com/engine/containers/run/#runtime-privilege-and-linux-capabilities) can be added to your templates to add docker support.
|
||||
This may come in handy if your nodes cannot run Sysbox.
|
||||
This can come in handy if your nodes cannot run Sysbox.
|
||||
|
||||
> [!WARNING]
|
||||
> This is insecure.
|
||||
|
||||
Generated
+3
-3
@@ -18,8 +18,8 @@ coder templates init [flags] [directory]
|
||||
|
||||
### --id
|
||||
|
||||
| Property | Value |
|
||||
|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| Type | <code>aws-devcontainer\|aws-linux\|aws-windows\|azure-linux\|digitalocean-linux\|docker\|docker-devcontainer\|docker-envbuilder\|gcp-devcontainer\|gcp-linux\|gcp-vm-container\|gcp-windows\|incus\|kubernetes\|kubernetes-devcontainer\|nomad-docker\|quickstart\|scratch</code> |
|
||||
| Property | Value |
|
||||
|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| Type | <code>aws-devcontainer\|aws-linux\|aws-windows\|azure-linux\|digitalocean-linux\|docker\|docker-devcontainer\|docker-envbuilder\|gcp-devcontainer\|gcp-linux\|gcp-vm-container\|gcp-windows\|incus\|kubernetes\|kubernetes-devcontainer\|kubernetes-podman-rootless\|nomad-docker\|quickstart\|scratch</code> |
|
||||
|
||||
Specify a given example template by ID.
|
||||
@@ -198,6 +198,19 @@
|
||||
],
|
||||
"markdown": "\n# Remote Development on Kubernetes Pods (with Devcontainers)\n\nProvision Devcontainers as [Coder workspaces](https://coder.com/docs/user-guides/workspace-management) on Kubernetes with this example template.\n\n## Prerequisites\n\n### Infrastructure\n\n**Cluster**: This template requires an existing Kubernetes cluster.\n\n**Container Image**: This template uses the [envbuilder image](https://github.com/coder/envbuilder) to build a Devcontainer from a `devcontainer.json`.\n\n**(Optional) Cache Registry**: Envbuilder can utilize a Docker registry as a cache to speed up workspace builds. The [envbuilder Terraform provider](https://github.com/coder/terraform-provider-envbuilder) 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.\n\n### Authentication\n\nThis 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](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs#authentication), edit the template.\n\n## Architecture\n\nCoder supports devcontainers with [envbuilder](https://github.com/coder/envbuilder), an open source project. Read more about this in [Coder's documentation](https://coder.com/docs/admin/integrations/devcontainers).\n\nThis template provisions the following resources:\n\n- Kubernetes deployment (ephemeral)\n- Kubernetes persistent volume claim (persistent on `/workspaces`)\n- Envbuilder cached image (optional, persistent).\n\nThis template will fetch a Git repo containing a `devcontainer.json` specified by the `repo` parameter, and builds it\nwith [`envbuilder`](https://github.com/coder/envbuilder).\nThe Git repository is cloned inside the `/workspaces` volume if not present.\nAny local changes to the Devcontainer files inside the volume will be applied when you restart the workspace.\nAs you might suspect, any tools or files outside of `/workspaces` or not added as part of the Devcontainer specification are not persisted.\nEdit the `devcontainer.json` instead!\n\n\u003e **Note**\n\u003e This template is designed to be a starting point! Edit the Terraform to extend the template to support your use case.\n\n## Caching\n\nTo speed up your builds, you can use a container registry as a cache.\nWhen creating the template, set the parameter `cache_repo`.\n\nSee the [Envbuilder Terraform Provider Examples](https://github.com/coder/terraform-provider-envbuilder/blob/main/examples/resources/envbuilder_cached_image/envbuilder_cached_image_resource.tf/) for a more complete example of how the provider works.\n\n\u003e [!NOTE]\n\u003e We recommend using a registry cache with authentication enabled.\n\u003e To allow Envbuilder to authenticate with the registry cache, specify the variable `cache_repo_dockerconfig_secret`\n\u003e with the name of a Kubernetes secret in the same namespace as Coder. The secret must contain the key `.dockerconfigjson`.\n"
|
||||
},
|
||||
{
|
||||
"id": "kubernetes-podman-rootless",
|
||||
"url": "",
|
||||
"name": "Kubernetes (Rootless Podman)",
|
||||
"description": "Provision rootless Podman pods as Coder workspaces",
|
||||
"icon": "/icon/k8s.png",
|
||||
"tags": [
|
||||
"container",
|
||||
"kubernetes",
|
||||
"podman"
|
||||
],
|
||||
"markdown": "\n# Remote development on Kubernetes with rootless Podman\n\nProvision workspaces that run containers with rootless Podman, without privileged pods or a custom container runtime.\n\nThe workspace pod runs as a non-root user.\nPodman uses native kernel overlay storage, so the `/dev/fuse` device plugin is not required on nodes with kernel 5.13 or later.\nThe agent starts a Docker-compatible API socket for tools such as Testcontainers and Docker Compose.\n\n## Prerequisites\n\n- Nodes with `user.max_user_namespaces` set above `0`.\n Refer to [Docker in workspaces](https://coder.com/docs/admin/templates/extending-templates/docker-in-workspaces#rootless-podman) for per-platform instructions, including EKS Auto Mode.\n If only some nodes qualify, set the `node_selector` variable to schedule workspaces onto them.\n- The Coder provisioner needs permission to create pods in the target namespace.\n\n## Notes\n\n- The home directory is a persistent volume, so cloned repositories, pulled images, and build cache survive workspace restarts.\n The volume must be ext4 or xfs for native overlay storage, which most default storage classes provide.\n- If Podman can't start its API socket, for example because user namespaces are disabled on the node, the startup script fails and prints the Podman error to the startup logs.\n- One level of container nesting is supported.\n For dev containers, use the `docker-outside-of-docker` feature.\n Refer to [Docker in workspaces](https://coder.com/docs/admin/templates/extending-templates/docker-in-workspaces#nested-container-engines).\n"
|
||||
},
|
||||
{
|
||||
"id": "nomad-docker",
|
||||
"url": "",
|
||||
|
||||
@@ -39,6 +39,7 @@ var (
|
||||
//go:embed templates/incus
|
||||
//go:embed templates/kubernetes
|
||||
//go:embed templates/kubernetes-devcontainer
|
||||
//go:embed templates/kubernetes-podman-rootless
|
||||
//go:embed templates/nomad-docker
|
||||
//go:embed templates/quickstart
|
||||
//go:embed templates/scratch
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
display_name: Kubernetes (Rootless Podman)
|
||||
description: Provision rootless Podman pods as Coder workspaces
|
||||
icon: ../../../site/static/icon/k8s.png
|
||||
maintainer_github: coder
|
||||
verified: true
|
||||
tags: [container, kubernetes, podman]
|
||||
---
|
||||
|
||||
# Remote development on Kubernetes with rootless Podman
|
||||
|
||||
Provision workspaces that run containers with rootless Podman, without privileged pods or a custom container runtime.
|
||||
|
||||
The workspace pod runs as a non-root user.
|
||||
Podman uses native kernel overlay storage, so the `/dev/fuse` device plugin is not required on nodes with kernel 5.13 or later.
|
||||
The agent starts a Docker-compatible API socket for tools such as Testcontainers and Docker Compose.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Nodes with `user.max_user_namespaces` set above `0`.
|
||||
Refer to [Docker in workspaces](https://coder.com/docs/admin/templates/extending-templates/docker-in-workspaces#rootless-podman) for per-platform instructions, including EKS Auto Mode.
|
||||
If only some nodes qualify, set the `node_selector` variable to schedule workspaces onto them.
|
||||
- The Coder provisioner needs permission to create pods in the target namespace.
|
||||
|
||||
## Notes
|
||||
|
||||
- The home directory is a persistent volume, so cloned repositories, pulled images, and build cache survive workspace restarts.
|
||||
The volume must be ext4 or xfs for native overlay storage, which most default storage classes provide.
|
||||
- If Podman can't start its API socket, for example because user namespaces are disabled on the node, the startup script fails and prints the Podman error to the startup logs.
|
||||
- One level of container nesting is supported.
|
||||
For dev containers, use the `docker-outside-of-docker` feature.
|
||||
Refer to [Docker in workspaces](https://coder.com/docs/admin/templates/extending-templates/docker-in-workspaces#nested-container-engines).
|
||||
@@ -0,0 +1,162 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
coder = {
|
||||
source = "coder/coder"
|
||||
}
|
||||
kubernetes = {
|
||||
source = "hashicorp/kubernetes"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "coder" {}
|
||||
|
||||
variable "namespace" {
|
||||
type = string
|
||||
description = "The Kubernetes namespace to create workspace pods in."
|
||||
default = "coder"
|
||||
}
|
||||
|
||||
variable "node_selector" {
|
||||
type = map(string)
|
||||
description = "Node labels for nodes with user namespaces enabled, for example an EKS Auto Mode NodePool with advancedCompute."
|
||||
default = {}
|
||||
}
|
||||
|
||||
provider "kubernetes" {
|
||||
# Authenticates with the service account of the Coder provisioner.
|
||||
config_path = null
|
||||
}
|
||||
|
||||
data "coder_workspace" "me" {}
|
||||
data "coder_workspace_owner" "me" {}
|
||||
|
||||
data "coder_parameter" "home_disk_size" {
|
||||
name = "home_disk_size"
|
||||
display_name = "Home disk size"
|
||||
description = "The size of the home disk in GB, including Podman images and build cache"
|
||||
default = "20"
|
||||
type = "number"
|
||||
icon = "/emojis/1f4be.png"
|
||||
mutable = false
|
||||
validation {
|
||||
min = 1
|
||||
max = 99999
|
||||
}
|
||||
}
|
||||
|
||||
resource "coder_agent" "main" {
|
||||
os = "linux"
|
||||
arch = "amd64"
|
||||
startup_script = <<-EOT
|
||||
#!/bin/bash
|
||||
# Seed shell dotfiles that the empty home volume hides on first start.
|
||||
[ -f ~/.bashrc ] || cp -rT /etc/skel ~ || true
|
||||
# Use native kernel overlay storage. Some Podman images pin
|
||||
# mount_program to fuse-overlayfs in /etc/containers/storage.conf.
|
||||
mkdir -p ~/.config/containers
|
||||
printf '[storage]\ndriver = "overlay"\n\n[storage.options.overlay]\nmount_program = ""\n' > ~/.config/containers/storage.conf
|
||||
# Docker-compatible API socket for Testcontainers, Compose, and
|
||||
# the dev container docker-outside-of-docker feature.
|
||||
(podman system service --time=0 unix:///tmp/podman.sock >/tmp/podman-service.log 2>&1 &)
|
||||
for i in $(seq 50); do [ -S /tmp/podman.sock ] && break; sleep 0.1; done
|
||||
if [ ! -S /tmp/podman.sock ]; then
|
||||
echo "Podman API socket didn't start:" >&2
|
||||
cat /tmp/podman-service.log >&2
|
||||
exit 1
|
||||
fi
|
||||
EOT
|
||||
|
||||
env = {
|
||||
DOCKER_HOST = "unix:///tmp/podman.sock"
|
||||
# BuildKit can't start inside the workspace; use the classic builder
|
||||
# for docker build and docker compose build.
|
||||
DOCKER_BUILDKIT = "0"
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_persistent_volume_claim_v1" "home" {
|
||||
metadata {
|
||||
name = "coder-${data.coder_workspace.me.id}-home"
|
||||
namespace = var.namespace
|
||||
labels = {
|
||||
"app.kubernetes.io/name" = "coder-pvc"
|
||||
"app.kubernetes.io/instance" = "coder-pvc-${data.coder_workspace.me.id}"
|
||||
"app.kubernetes.io/part-of" = "coder"
|
||||
//Coder-specific labels.
|
||||
"com.coder.resource" = "true"
|
||||
"com.coder.workspace.id" = data.coder_workspace.me.id
|
||||
"com.coder.workspace.name" = data.coder_workspace.me.name
|
||||
"com.coder.user.id" = data.coder_workspace_owner.me.id
|
||||
"com.coder.user.username" = data.coder_workspace_owner.me.name
|
||||
}
|
||||
annotations = {
|
||||
"com.coder.user.email" = data.coder_workspace_owner.me.email
|
||||
}
|
||||
}
|
||||
wait_until_bound = false
|
||||
spec {
|
||||
access_modes = ["ReadWriteOnce"]
|
||||
resources {
|
||||
requests = {
|
||||
storage = "${data.coder_parameter.home_disk_size.value}Gi"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_pod_v1" "main" {
|
||||
count = data.coder_workspace.me.start_count
|
||||
metadata {
|
||||
name = "coder-${lower(data.coder_workspace_owner.me.name)}-${lower(data.coder_workspace.me.name)}"
|
||||
namespace = var.namespace
|
||||
annotations = {
|
||||
# Allow Podman to create nested user namespaces on AppArmor hosts
|
||||
# such as GKE and Ubuntu nodes. Ignored where AppArmor is absent.
|
||||
"container.apparmor.security.beta.kubernetes.io/dev" = "unconfined"
|
||||
}
|
||||
}
|
||||
spec {
|
||||
# The codercom/example-podman image is published for amd64 only.
|
||||
node_selector = merge({ "kubernetes.io/arch" = "amd64" }, var.node_selector)
|
||||
security_context {
|
||||
run_as_user = 1000
|
||||
fs_group = 1000
|
||||
run_as_non_root = true
|
||||
# Skip the recursive chgrp on every start, which would rewrite the
|
||||
# subuid-owned image layers in the Podman graph root.
|
||||
fs_group_change_policy = "OnRootMismatch"
|
||||
}
|
||||
container {
|
||||
name = "dev"
|
||||
image = "codercom/example-podman:ubuntu"
|
||||
command = ["sh", "-c", coder_agent.main.init_script]
|
||||
env {
|
||||
name = "CODER_AGENT_TOKEN"
|
||||
value = coder_agent.main.token
|
||||
}
|
||||
resources {
|
||||
requests = {
|
||||
cpu = "500m"
|
||||
memory = "1Gi"
|
||||
}
|
||||
limits = {
|
||||
cpu = "2"
|
||||
memory = "4Gi"
|
||||
}
|
||||
}
|
||||
# The Podman graph root lives under home on this ext4 or xfs volume,
|
||||
# so kernel overlay works and images persist across restarts.
|
||||
volume_mount {
|
||||
name = "home"
|
||||
mount_path = "/home/coder"
|
||||
}
|
||||
}
|
||||
volume {
|
||||
name = "home"
|
||||
persistent_volume_claim {
|
||||
claim_name = kubernetes_persistent_volume_claim_v1.home.metadata[0].name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user