-
Notifications
You must be signed in to change notification settings - Fork 73
feat: dynamic username template #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c9e0de0
feat: dynamic username template
ericpaulsen e7a93c4
feedback changes
ericpaulsen 065489d
Merge branch 'main' into ericpaulsen-template-pod-username
ericpaulsen 9db922a
bun fmt
ericpaulsen 46d3a05
bun fmt v2
ericpaulsen 7b248fb
rm code-server & add vs code web module
ericpaulsen 14b95d3
add subdir for template
ericpaulsen a04c714
Merge branch 'main' into ericpaulsen-template-pod-username
phorcys420 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
display_name: "Eric Paulsen" | ||
bio: "Field CTO, EMEA @ Coder" | ||
avatar_url: "./.images/avatar.png" | ||
github: "ericpaulsen" | ||
linkedin: "https://www.linkedin.com/in/ericpaulsen17" # Optional | ||
website: "https://ericpaulsen.io" # Optional | ||
support_email: "[email protected]" # Optional | ||
status: "coder" | ||
--- | ||
|
||
# Eric Paulsen | ||
|
||
I'm Eric Paulsen, Coder's EMEA Field CTO based in London, originating from Miami. | ||
Outside of working with our customers, I enjoy teaching myself things, | ||
playing volleyball, and dabbling in a bit of DJing & photography. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
display_name: Kubernetes (Deployment) with Dynamic Username | ||
description: Provision Kubernetes Deployments as Coder workspaces with your Username | ||
icon: ../../../site/static/icon/k8s.png | ||
maintainer_github: ericpaulsen | ||
ericpaulsen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
verified: true | ||
tags: [kubernetes, container] | ||
--- | ||
|
||
# Remote development on Kubernetes with dynamic usernames | ||
|
||
Provision Kubernetes Pods as [Coder workspaces](https://coder.com/docs/workspaces) with this example template. This template | ||
will run the workspace container as a non-root UID using your Coder username. | ||
|
||
Here is the entrypoint logic in the template that enables Coder to source your username and write it to the Ubuntu operating system at start-up. | ||
|
||
> These commands may differ if you run your workspace image with a distro other than Ubuntu. | ||
|
||
```terraform | ||
command = ["sh", "-c", <<EOF | ||
# Create user and setup home directory | ||
sudo useradd ${data.coder_workspace_owner.me.name} --home=/home/${data.coder_workspace_owner.me.name} --shell=/bin/bash --uid=1001 --user-group | ||
sudo chown -R ${data.coder_workspace_owner.me.name}:${data.coder_workspace_owner.me.name} /home/${data.coder_workspace_owner.me.name} | ||
|
||
# Switch to user and run agent | ||
exec sudo --preserve-env=CODER_AGENT_TOKEN -u ${data.coder_workspace_owner.me.name} sh -c '${coder_agent.main.init_script}' | ||
EOF | ||
] | ||
``` | ||
|
||
<!-- TODO: Add screenshot --> | ||
|
||
## Prerequisites | ||
|
||
### Infrastructure | ||
|
||
**Cluster**: This template requires an existing Kubernetes cluster | ||
|
||
**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. | ||
|
||
### 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](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs#authentication), edit the template. | ||
|
||
## Architecture | ||
|
||
This template provisions the following resources: | ||
|
||
- Kubernetes Deployment (ephemeral) | ||
- Kubernetes persistent volume claim (persistent on `/home/coder`) | ||
ericpaulsen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
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. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.