From 3ca0ae51c42a52b4ae79300f5512d74e7f13fdf0 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Wed, 7 Jun 2023 14:32:53 +0000 Subject: [PATCH 1/2] chore: update envbox template legacy parameters --- examples/templates/envbox/README.md | 14 ++++++++++++++ examples/templates/envbox/main.tf | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/examples/templates/envbox/README.md b/examples/templates/envbox/README.md index bea44c48bc6b0..a1869f329c1d9 100644 --- a/examples/templates/envbox/README.md +++ b/examples/templates/envbox/README.md @@ -27,6 +27,20 @@ The following environment variables can be used to configure various aspects of | `CODER_CPUS` | Dictates the number of CPUs to allocate the inner container. It is recommended to set this using the Kubernetes [Downward API](https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/#use-container-fields-as-values-for-environment-variables). | false | | `CODER_MEMORY` | Dictates the max memory (in bytes) to allocate the inner container. It is recommended to set this using the Kubernetes [Downward API](https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/#use-container-fields-as-values-for-environment-variables). | false | +# Migrating Existing Envbox Templates + +Due to the [deprecation and removal of legacy parameters](https://coder.com/docs/v2/latest/templates/parameters#legacy) +it may be necessary to migrate existing envbox templates on newer versions of +Coder. Consult the [migration](https://coder.com/docs/v2/latest/templates/parameters#migration) +documentation for details on how to do so. + +To supply values to existing existing Terraform variables you can specify the +`--variable` flag. For example + +```bash +coder templates create test --variable namespace="mynamespace" --variable max_cpus=2 --variable min_cpus=1 --variable max_memory=4 --variable min_memory=1 +``` + ## Contributions Contributions are welcome and can be made against the [envbox repo](https://github.com/coder/envbox). diff --git a/examples/templates/envbox/main.tf b/examples/templates/envbox/main.tf index 225e42705ffef..1e4e49b5e280c 100644 --- a/examples/templates/envbox/main.tf +++ b/examples/templates/envbox/main.tf @@ -27,6 +27,7 @@ data "coder_parameter" "home_disk" { variable "use_kubeconfig" { type = bool sensitive = true + default = 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 @@ -36,6 +37,10 @@ variable "use_kubeconfig" { EOF } +provider "coder" { + feature_use_managed_variables = "true" +} + variable "namespace" { type = string sensitive = true @@ -46,12 +51,14 @@ variable "create_tun" { type = bool sensitive = true description = "Add a TUN device to the workspace." + default = false } variable "create_fuse" { type = bool description = "Add a FUSE device to the workspace." sensitive = true + default = false } variable "max_cpus" { @@ -138,11 +145,15 @@ resource "kubernetes_persistent_volume_claim" "home" { resource "kubernetes_pod" "main" { count = data.coder_workspace.me.start_count + metadata { name = "coder-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}" namespace = var.namespace } + spec { + restart_policy = "Never" + container { name = "dev" image = "ghcr.io/coder/envbox:latest" From 1ada8f6b0d8b0a2d786488bb87ae0481e984c0af Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Wed, 7 Jun 2023 14:35:44 +0000 Subject: [PATCH 2/2] update example cmd --- examples/templates/envbox/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/templates/envbox/README.md b/examples/templates/envbox/README.md index a1869f329c1d9..5b8672358df81 100644 --- a/examples/templates/envbox/README.md +++ b/examples/templates/envbox/README.md @@ -38,7 +38,7 @@ To supply values to existing existing Terraform variables you can specify the `--variable` flag. For example ```bash -coder templates create test --variable namespace="mynamespace" --variable max_cpus=2 --variable min_cpus=1 --variable max_memory=4 --variable min_memory=1 +coder templates create envbox --variable namespace="mynamespace" --variable max_cpus=2 --variable min_cpus=1 --variable max_memory=4 --variable min_memory=1 ``` ## Contributions