Skip to content

fix(templates): add resources to k8s example templates #6310

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion examples/templates/kubernetes-with-podman/main.tf
Original file line number Diff line number Diff line change
@@ -26,6 +26,36 @@ variable "os" {
default = "ubuntu"
}

variable "cpus" {
type = number
description = "How many CPUs would you like your workspace to have?"
default = 4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take with a grain of salt but IMO 1-2 cores might be better as a default.

validation {
condition = var.cpus > 0
error_message = "Value must be greater than 0."
}
}

variable "memory" {
type = number
description = "How much memory would you like your workspace to have (in GiB)?"
default = 4
validation {
condition = var.memory > 0
error_message = "Value must be greater than 0."
}
}

variable "home_disk_size" {
type = number
description = "How large would you like your home volume to be (in GB)?"
default = 10
validation {
condition = var.home_disk_size >= 1
error_message = "Value must be greater than or equal to 1."
}
}

resource "coder_agent" "dev" {
os = "linux"
arch = "amd64"
@@ -112,7 +142,9 @@ resource "kubernetes_persistent_volume_claim" "home-directory" {
access_modes = ["ReadWriteOnce"]
resources {
requests = {
storage = "10Gi"
cpus = "${var.cpus}"
memory = "${var.memory}Gi"
storage = "${var.home_disk_size}Gi"
}
}
}
22 changes: 22 additions & 0 deletions examples/templates/kubernetes/main.tf
Original file line number Diff line number Diff line change
@@ -31,6 +31,26 @@ variable "namespace" {
description = "The Kubernetes namespace to create workspaces in (must exist prior to creating workspaces)"
}

variable "cpus" {
type = number
description = "How many CPUs would you like your workspace to have?"
default = 4
validation {
condition = var.cpus > 0
error_message = "Value must be greater than 0."
}
}

variable "memory" {
type = number
description = "How much memory would you like your workspace to have (in GiB)?"
default = 4
validation {
condition = var.memory > 0
error_message = "Value must be greater than 0."
}
}

variable "home_disk_size" {
type = number
description = "How large would you like your home volume to be (in GB)?"
@@ -104,6 +124,8 @@ resource "kubernetes_persistent_volume_claim" "home" {
access_modes = ["ReadWriteOnce"]
resources {
requests = {
cpus = "${var.cpus}"
memory = "${var.memory}Gi"
storage = "${var.home_disk_size}Gi"
}
}