diff --git a/registry/ericpaulsen/.images/avatar.png b/registry/ericpaulsen/.images/avatar.png new file mode 100644 index 000000000..cbd947af3 Binary files /dev/null and b/registry/ericpaulsen/.images/avatar.png differ diff --git a/registry/ericpaulsen/README.md b/registry/ericpaulsen/README.md new file mode 100644 index 000000000..585b99480 --- /dev/null +++ b/registry/ericpaulsen/README.md @@ -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: "ericpaulsen@hey.com" # Optional +status: "community" +--- + +# 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. diff --git a/registry/ericpaulsen/templates/k8s-username/README.md b/registry/ericpaulsen/templates/k8s-username/README.md new file mode 100644 index 000000000..ec106a505 --- /dev/null +++ b/registry/ericpaulsen/templates/k8s-username/README.md @@ -0,0 +1,51 @@ +--- +display_name: Kubernetes (Deployment) with Dynamic Username +description: Provision Kubernetes Deployments as Coder workspaces with your Username +icon: ../../../site/static/icon/k8s.png +verified: true +tags: [kubernetes, container, username] +--- + +# 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", < + +## 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/${username}`, where `${username}` is your Coder username) + +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. diff --git a/registry/ericpaulsen/templates/k8s-username/main.tf b/registry/ericpaulsen/templates/k8s-username/main.tf new file mode 100644 index 000000000..ee632f9d1 --- /dev/null +++ b/registry/ericpaulsen/templates/k8s-username/main.tf @@ -0,0 +1,327 @@ +terraform { + required_providers { + coder = { + source = "coder/coder" + } + kubernetes = { + source = "hashicorp/kubernetes" + } + } +} + +provider "coder" { +} + +variable "use_kubeconfig" { + type = bool + description = <<-EOF + Use host kubeconfig? (true/false) + + Set this to false if the Coder host is itself running as a Pod on the same + Kubernetes cluster as you are deploying workspaces to. + + Set this to true if the Coder host is running outside the Kubernetes cluster + for workspaces. A valid "~/.kube/config" must be present on the Coder host. + EOF + default = false +} + +variable "namespace" { + type = string + 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." +} + +data "coder_parameter" "cpu" { + name = "cpu" + display_name = "CPU" + description = "The number of CPU cores" + default = "2" + icon = "/icon/memory.svg" + mutable = true + option { + name = "2 Cores" + value = "2" + } + option { + name = "4 Cores" + value = "4" + } + option { + name = "6 Cores" + value = "6" + } + option { + name = "8 Cores" + value = "8" + } +} + +data "coder_parameter" "memory" { + name = "memory" + display_name = "Memory" + description = "The amount of memory in GB" + default = "2" + icon = "/icon/memory.svg" + mutable = true + option { + name = "2 GB" + value = "2" + } + option { + name = "4 GB" + value = "4" + } + option { + name = "6 GB" + value = "6" + } + option { + name = "8 GB" + value = "8" + } +} + +data "coder_parameter" "home_disk_size" { + name = "home_disk_size" + display_name = "Home disk size" + description = "The size of the home disk in GB" + default = "10" + type = "number" + icon = "/emojis/1f4be.png" + mutable = false + validation { + min = 1 + max = 99999 + } +} + +provider "kubernetes" { + # Authenticate via ~/.kube/config or a Coder-specific ServiceAccount, depending on admin preferences + config_path = var.use_kubeconfig == true ? "~/.kube/config" : null +} + +data "coder_workspace" "me" {} +data "coder_workspace_owner" "me" {} + +module "vscode-web" { + count = data.coder_workspace.me.start_count + source = "registry.coder.com/coder/vscode-web/coder" + version = "1.3.1" + agent_id = coder_agent.main.id + accept_license = true +} + +resource "coder_agent" "main" { + os = "linux" + arch = "amd64" + + # The following metadata blocks are optional. They are used to display + # information about your workspace in the dashboard. You can remove them + # if you don't want to display any information. + # For basic resources, you can use the `coder stat` command. + # If you need more control, you can write your own script. + metadata { + display_name = "CPU Usage" + key = "0_cpu_usage" + script = "coder stat cpu" + interval = 10 + timeout = 1 + } + + metadata { + display_name = "RAM Usage" + key = "1_ram_usage" + script = "coder stat mem" + interval = 10 + timeout = 1 + } + + metadata { + display_name = "Home Disk" + key = "3_home_disk" + script = "coder stat disk --path $${HOME}" + interval = 60 + timeout = 1 + } + + metadata { + display_name = "CPU Usage (Host)" + key = "4_cpu_usage_host" + script = "coder stat cpu --host" + interval = 10 + timeout = 1 + } + + metadata { + display_name = "Memory Usage (Host)" + key = "5_mem_usage_host" + script = "coder stat mem --host" + interval = 10 + timeout = 1 + } + + metadata { + display_name = "Load Average (Host)" + key = "6_load_host" + # get load avg scaled by number of cores + script = <