mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
* Pass workspace owner email address to provisioner * Remove owner_email and owner_username fields from agent metadata * Add Git environment variables to example templates * Remove "owner_name" field from provisioner metadata, use username instead * Remove Git configuration from most templates, add documentation * Proofreading/typo fixes from @mafredri * Update example templates to latest version of terraform-provider-coder
102 lines
2.5 KiB
HCL
102 lines
2.5 KiB
HCL
terraform {
|
|
required_providers {
|
|
coder = {
|
|
source = "coder/coder"
|
|
version = "~> 0.4.3"
|
|
}
|
|
kubernetes = {
|
|
source = "hashicorp/kubernetes"
|
|
version = "~> 2.10"
|
|
}
|
|
}
|
|
}
|
|
|
|
variable "use_kubeconfig" {
|
|
type = bool
|
|
sensitive = true
|
|
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
|
|
}
|
|
|
|
variable "workspaces_namespace" {
|
|
type = string
|
|
sensitive = true
|
|
description = "The namespace to create workspaces in (must exist prior to creating workspaces)"
|
|
default = "coder-workspaces"
|
|
}
|
|
|
|
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" {}
|
|
|
|
resource "coder_agent" "go" {
|
|
os = "linux"
|
|
arch = "amd64"
|
|
}
|
|
|
|
resource "coder_agent" "java" {
|
|
os = "linux"
|
|
arch = "amd64"
|
|
}
|
|
|
|
resource "coder_agent" "ubuntu" {
|
|
os = "linux"
|
|
arch = "amd64"
|
|
}
|
|
|
|
resource "kubernetes_pod" "main" {
|
|
count = data.coder_workspace.me.start_count
|
|
metadata {
|
|
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
|
|
namespace = var.workspaces_namespace
|
|
}
|
|
spec {
|
|
container {
|
|
name = "go"
|
|
image = "mcr.microsoft.com/vscode/devcontainers/go:1"
|
|
command = ["sh", "-c", coder_agent.go.init_script]
|
|
security_context {
|
|
run_as_user = "1000"
|
|
}
|
|
env {
|
|
name = "CODER_AGENT_TOKEN"
|
|
value = coder_agent.go.token
|
|
}
|
|
}
|
|
container {
|
|
name = "java"
|
|
image = "mcr.microsoft.com/vscode/devcontainers/java"
|
|
command = ["sh", "-c", coder_agent.java.init_script]
|
|
security_context {
|
|
run_as_user = "1000"
|
|
}
|
|
env {
|
|
name = "CODER_AGENT_TOKEN"
|
|
value = coder_agent.java.token
|
|
}
|
|
}
|
|
container {
|
|
name = "ubuntu"
|
|
image = "mcr.microsoft.com/vscode/devcontainers/base:ubuntu"
|
|
command = ["sh", "-c", coder_agent.ubuntu.init_script]
|
|
security_context {
|
|
run_as_user = "1000"
|
|
}
|
|
env {
|
|
name = "CODER_AGENT_TOKEN"
|
|
value = coder_agent.ubuntu.token
|
|
}
|
|
}
|
|
}
|
|
}
|