Skip to content

Commit 6e1f0aa

Browse files
committed
add: offical kubernetes provider runtime_class_name
1 parent 913e461 commit 6e1f0aa

File tree

1 file changed

+44
-25
lines changed

1 file changed

+44
-25
lines changed

docs/templates/docker-in-docker.md

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The [Sysbox](https://github.com/nestybox/sysbox) container runtime allows unpriv
66

77
> Sysbox can also be used to run systemd inside Coder workspaces. See [Systemd in Docker](#systemd-in-docker).
88
9-
### Use Sysbox in Docker-based templates:
9+
### Use Sysbox in Docker-based templates
1010

1111
After [installing Sysbox](https://github.com/nestybox/sysbox#installation) on the Coder host, modify your template to use the sysbox-runc runtime:
1212

@@ -35,13 +35,23 @@ resource "coder_agent" "main" {
3535
}
3636
```
3737

38-
### Use Sysbox in Kubernetes-based templates:
38+
### Use Sysbox in Kubernetes-based templates
3939

40-
After [installing Sysbox on Kubernetes](https://github.com/nestybox/sysbox/blob/master/docs/user-guide/install-k8s.md), modify your template to use the sysbox-runc RuntimeClass.
41-
42-
> Currently, the official [Kubernetes Terraform Provider](https://registry.terraform.io/providers/hashicorp/kubernetes/latest) does not support specifying a custom RuntimeClass. [mingfang/k8s](https://registry.terraform.io/providers/mingfang/k8s), a third-party provider, can be used instead.
40+
After [installing Sysbox on Kubernetes](https://github.com/nestybox/sysbox/blob/master/docs/user-guide/install-k8s.md), modify your template to use the sysbox-runc RuntimeClass. This requires the Kuberentes Terrafom provider version 2.16.0 or greater.
4341

4442
```hcl
43+
terraform {
44+
required_providers {
45+
coder = {
46+
source = "coder/coder"
47+
}
48+
kubernetes = {
49+
source = "hashicorp/kubernetes"
50+
version = "2.16.0"
51+
}
52+
}
53+
}
54+
4555
resource "coder_agent" "main" {
4656
os = "linux"
4757
arch = "amd64"
@@ -56,7 +66,7 @@ resource "coder_agent" "main" {
5666
EOF
5767
}
5868
59-
resource "k8s_core_v1_pod" "dev" {
69+
resource "kubernetes_pod" "dev" {
6070
count = data.coder_workspace.me.start_count
6171
metadata {
6272
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
@@ -66,15 +76,14 @@ resource "k8s_core_v1_pod" "dev" {
6676
}
6777
}
6878
69-
7079
spec {
7180
runtime_class_name = "sysbox-runc"
7281
# Use the Sysbox container runtime (required)
7382
security_context {
74-
run_asuser = 1000
75-
fsgroup = 1000
83+
run_as_user = 1000
84+
fs_group = 1000
7685
}
77-
containers {
86+
container {
7887
name = "dev"
7988
env {
8089
name = "CODER_AGENT_TOKEN"
@@ -93,7 +102,7 @@ resource "k8s_core_v1_pod" "dev" {
93102

94103
While less secure, you can attach a [privileged container](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities) to your templates. This may come in handy if your nodes cannot run Sysbox.
95104

96-
### Use a privileged sidecar container in Docker-based templates:
105+
### Use a privileged sidecar container in Docker-based templates
97106

98107
```hcl
99108
resource "coder_agent" "main" {
@@ -130,9 +139,21 @@ resource "docker_container" "workspace" {
130139
}
131140
```
132141

133-
### Use a privileged sidecar container in Kubernetes-based templates:
142+
### Use a privileged sidecar container in Kubernetes-based templates
134143

135144
```hcl
145+
terraform {
146+
required_providers {
147+
coder = {
148+
source = "coder/coder"
149+
}
150+
kubernetes = {
151+
source = "hashicorp/kubernetes"
152+
version = "2.16.0"
153+
}
154+
}
155+
}
156+
136157
resource "coder_agent" "main" {
137158
os = "linux"
138159
arch = "amd64"
@@ -179,7 +200,7 @@ resource "kubernetes_pod" "main" {
179200

180201
Additionally, [Sysbox](https://github.com/nestybox/sysbox) can be used to give workspaces full `systemd` capabilities.
181202

182-
### Use systemd in Docker-based templates:
203+
### Use systemd in Docker-based templates
183204

184205
After [installing Sysbox](https://github.com/nestybox/sysbox#installation) on the Coder host, modify your template to use the sysbox-runc runtime and start systemd:
185206

@@ -219,32 +240,31 @@ resource "coder_agent" "main" {
219240
}
220241
```
221242

222-
### Use systemd in Kubernetes-based templates:
223-
224-
After [installing Sysbox on Kubernetes](https://github.com/nestybox/sysbox/blob/master/docs/user-guide/install-k8s.md), modify your template to use the sysbox-runc RuntimeClass.
243+
### Use systemd in Kubernetes-based templates
225244

226-
> Currently, the official [Kubernetes Terraform Provider](https://registry.terraform.io/providers/hashicorp/kubernetes/latest) does not support specifying a custom RuntimeClass. [mingfang/k8s](https://registry.terraform.io/providers/mingfang/k8s), a third-party provider, can be used instead.
245+
After [installing Sysbox on Kubernetes](https://github.com/nestybox/sysbox/blob/master/docs/user-guide/install-k8s.md),
246+
modify your template to use the sysbox-runc RuntimeClass. This requires the Kuberentes Terrafom provider version 2.16.0 or greater.
227247

228248
```hcl
229249
terraform {
230250
required_providers {
231251
coder = {
232252
source = "coder/coder"
233253
}
234-
k8s = {
235-
source = "mingfang/k8s"
254+
kubernetes = {
255+
source = "hashicorp/kubernetes"
256+
version = "2.16.0"
236257
}
237258
}
238259
}
239260
240-
241261
resource "coder_agent" "main" {
242262
os = "linux"
243263
arch = "amd64"
244264
dir = "/home/coder"
245265
}
246266
247-
resource "k8s_core_v1_pod" "dev" {
267+
resource "kubernetes_pod" "dev" {
248268
count = data.coder_workspace.me.start_count
249269
metadata {
250270
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
@@ -254,19 +274,18 @@ resource "k8s_core_v1_pod" "dev" {
254274
}
255275
}
256276
257-
258277
spec {
259278
260279
# Use Sysbox container runtime (required)
261280
runtime_class_name = "sysbox-runc"
262281
263282
# Run as root in order to start systemd (required)
264283
security_context {
265-
run_asuser = 0
266-
fsgroup = 0
284+
run_as_user = 0
285+
fs_group = 0
267286
}
268287
269-
containers {
288+
container {
270289
name = "dev"
271290
env {
272291
name = "CODER_AGENT_TOKEN"

0 commit comments

Comments
 (0)