You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Description
this PR adds a new template that creates & runs Coder workspaces on K8s
with the user's Coder `username` as the Linux UID. a commonly requested
use-case by customers.
## Type of Change
- [x] New module
- [ ] Bug fix
- [ ] Feature/enhancement
- [ ] Documentation
- [ ] Other
## Module Information
<!-- Delete this section if not applicable -->
**Path:** `registry/ericpaulsen/templates/k8s-pod-username.tf`
## Testing & Validation
- [x] Changes tested locally
exec sudo --preserve-env=CODER_AGENT_TOKEN -u ${data.coder_workspace_owner.me.name} sh -c '${coder_agent.main.init_script}'
26
+
EOF
27
+
]
28
+
```
29
+
30
+
<!-- TODO: Add screenshot -->
31
+
32
+
## Prerequisites
33
+
34
+
### Infrastructure
35
+
36
+
**Cluster**: This template requires an existing Kubernetes cluster
37
+
38
+
**Container Image**: This template uses the [codercom/enterprise-base:ubuntu image](https://github.com/coder/enterprise-images/tree/main/images/base) with some dev tools preinstalled. To add additional tools, extend this image or build it yourself.
39
+
40
+
### Authentication
41
+
42
+
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](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs#authentication), edit the template.
43
+
44
+
## Architecture
45
+
46
+
This template provisions the following resources:
47
+
48
+
- Kubernetes Deployment (ephemeral)
49
+
- Kubernetes persistent volume claim (persistent on `/home/${username}`, where `${username}` is your Coder username)
50
+
51
+
This means, when the workspace restarts, any tools or files outside of the home directory are not persisted. To pre-bake tools into the workspace (e.g. `python3`), modify the container image. Alternatively, individual developers can [personalize](https://coder.com/docs/dotfiles) their workspaces with dotfiles.
Set this to false if the Coder host is itself running as a Pod on the same
21
+
Kubernetes cluster as you are deploying workspaces to.
22
+
23
+
Set this to true if the Coder host is running outside the Kubernetes cluster
24
+
for workspaces. A valid "~/.kube/config" must be present on the Coder host.
25
+
EOF
26
+
default=false
27
+
}
28
+
29
+
variable"namespace" {
30
+
type=string
31
+
description="The Kubernetes namespace to create workspaces in (must exist prior to creating workspaces). If the Coder host is itself running as a Pod on the same Kubernetes cluster as you are deploying workspaces to, set this to the same namespace."
32
+
}
33
+
34
+
data"coder_parameter""cpu" {
35
+
name="cpu"
36
+
display_name="CPU"
37
+
description="The number of CPU cores"
38
+
default="2"
39
+
icon="/icon/memory.svg"
40
+
mutable=true
41
+
option {
42
+
name="2 Cores"
43
+
value="2"
44
+
}
45
+
option {
46
+
name="4 Cores"
47
+
value="4"
48
+
}
49
+
option {
50
+
name="6 Cores"
51
+
value="6"
52
+
}
53
+
option {
54
+
name="8 Cores"
55
+
value="8"
56
+
}
57
+
}
58
+
59
+
data"coder_parameter""memory" {
60
+
name="memory"
61
+
display_name="Memory"
62
+
description="The amount of memory in GB"
63
+
default="2"
64
+
icon="/icon/memory.svg"
65
+
mutable=true
66
+
option {
67
+
name="2 GB"
68
+
value="2"
69
+
}
70
+
option {
71
+
name="4 GB"
72
+
value="4"
73
+
}
74
+
option {
75
+
name="6 GB"
76
+
value="6"
77
+
}
78
+
option {
79
+
name="8 GB"
80
+
value="8"
81
+
}
82
+
}
83
+
84
+
data"coder_parameter""home_disk_size" {
85
+
name="home_disk_size"
86
+
display_name="Home disk size"
87
+
description="The size of the home disk in GB"
88
+
default="10"
89
+
type="number"
90
+
icon="/emojis/1f4be.png"
91
+
mutable=false
92
+
validation {
93
+
min=1
94
+
max=99999
95
+
}
96
+
}
97
+
98
+
provider"kubernetes" {
99
+
# Authenticate via ~/.kube/config or a Coder-specific ServiceAccount, depending on admin preferences
0 commit comments