Skip to content

feat(100-cncf-cluster): expose script runtime env vars as Terraform variables #426

@katriendg

Description

@katriendg

Summary

Six environment variables in k3s-device-setup.sh are only available as
runtime placeholders ($${VAR}) in the ubuntu-k3s template locals. Unlike
SKIP_INSTALL_AZ_CLI and SKIP_AZ_LOGIN, which are properly wired through
Terraform variables using the var.x ? "true" : "$${X}" pattern, these six
remain opaque to Terraform callers.

Requested Variables

Script env var Proposed TF variable Type Default Purpose
SKIP_INSTALL_K3S should_skip_installing_k3s bool false Skip K3s installation entirely (server already has K3s)
K3S_VERSION k3s_version string null Pin K3s to a specific version (e.g. v1.31.2+k3s1)
SKIP_INSTALL_KUBECTL should_skip_installing_kubectl bool false Skip kubectl installation (already present)
SKIP_ARC_CONNECT should_skip_arc_connect bool false Skip Arc connect step (server only)
AZ_CLI_VER az_cli_version string null Pin Azure CLI to a specific version
AZ_CONNECTEDK8S_VER az_connectedk8s_version string null Pin connectedk8s extension version

Current Behavior

In src/100-edge/100-cncf-cluster/terraform/modules/ubuntu-k3s/main.tf:

SKIP_INSTALL_K3S      = "$${SKIP_INSTALL_K3S}"
K3S_VERSION           = "$${K3S_VERSION}"
SKIP_INSTALL_KUBECTL  = "$${SKIP_INSTALL_KUBECTL}"

These are pass-through placeholders that remain unset during Terraform
execution. The only way to control them today is to set host-level
environment variables before the script runs, which is not possible when
deploying via the Azure VM or Arc VM extension.

Expected Behavior

Follow the existing pattern used for SKIP_INSTALL_AZ_CLI:

# Current (wired correctly)
SKIP_INSTALL_AZ_CLI = var.should_skip_installing_az_cli ? "true" : "$${SKIP_INSTALL_AZ_CLI}"

# Requested (same pattern)
SKIP_INSTALL_K3S    = var.should_skip_installing_k3s ? "true" : "$${SKIP_INSTALL_K3S}"
K3S_VERSION         = try(coalesce(var.k3s_version), "$${K3S_VERSION}")

Scope

Component-level change only (100-cncf-cluster). No blueprint changes
required; consumers pass through the new variables from their wrapper modules.

Motivation

When deploying to servers that already have K3s installed (pre-provisioned
edge hardware, brownfield sites), the script currently:

  • Server nodes: detects existing K3s via command -v 'k3s' and skips
    (safe, but the kernel tuning block still runs unnecessarily).
  • Agent nodes: always re-runs curl -sfL https://get.k3s.io | sh - with
    no detection, causing unnecessary reinstalls on every terraform apply.

Exposing should_skip_installing_k3s lets callers explicitly declare that
K3s is pre-installed, skipping both the install and the kernel tuning block.
Exposing k3s_version lets callers pin versions for reproducible deployments
without relying on host-level env vars.

Affected Components

  • src/100-edge/100-cncf-cluster/terraform/variables.tf
  • src/100-edge/100-cncf-cluster/terraform/modules/ubuntu-k3s/main.tf
  • src/100-edge/100-cncf-cluster/terraform/modules/ubuntu-k3s/variables.tf

Affected Versions

  • v2.8.0 (confirmed)
  • Likely all versions since k3s-device-setup.sh was introduced

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions