Skip to content

chore: update legacy parameters in envbox template #7898

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 2 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions examples/templates/envbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 envbox --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).
11 changes: 11 additions & 0 deletions examples/templates/envbox/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,6 +37,10 @@ variable "use_kubeconfig" {
EOF
}

provider "coder" {
feature_use_managed_variables = "true"
}

variable "namespace" {
type = string
sensitive = true
Expand All @@ -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" {
Expand Down Expand Up @@ -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"
Expand Down