Skip to content

Rework testing cluster infra: K3s-over-SSH module + stable EKS node groups#37

Merged
thxCode merged 2 commits into
mainfrom
spec/testing-clusters-eks-and-k3s
Jul 15, 2026
Merged

Rework testing cluster infra: K3s-over-SSH module + stable EKS node groups#37
thxCode merged 2 commits into
mainfrom
spec/testing-clusters-eks-and-k3s

Conversation

@thxCode

@thxCode thxCode commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

What type of PR is this?

/kind enhancement
/kind bug
/kind cleanup
/area testing

What this PR does / why we need it:

Reworks testing/infra/clusters into predictable, single-purpose Terraform and adds a new K3s-over-SSH module.

New K3s module (testing/infra/clusters/k3s)

  • Installs/uninstalls K3s on SSH-reachable hosts via remote-exec, driven by server/agent host lists (user@host, per-role SSH ports). The first server bootstraps embedded etcd (--cluster-init); extra servers and agents join with a shared token; an empty agent list leaves the servers schedulable.
  • Reclaims each host before installing (uninstalls any pre-existing K3s) so a node carrying a prior/foreign deployment is redeployed cleanly instead of failing on stale etcd/token data.
  • release takes a K3s GitHub release tag (e.g. v1.34.9+k3s1) passed straight to INSTALL_K3S_VERSION.
  • flannel_backend selects the flannel backend (default vxlan; host-gw for faster node-to-node networking when all nodes share one L2 segment).
  • Fetches the kubeconfig, namespaces it to a k3s-<host> context, and flatten-merges it into ~/.kube/config (mode 600); destroy strips that context/cluster/user.

EKS module

  • Keys GPU node groups by name (map(list(string)) -> gpu-<name>) instead of positional list index, so adding or editing one entry no longer rotates the untouched node groups (the original bug).
  • Removes helm_release, the helm provider, var.image, and the gpustack_operator_image local, so the module only provisions the cluster.
  • Strips the cluster's context/cluster/user from ~/.kube/config on destroy via a self.triggers-only, on_failure = continue local-exec.

Which issue(s) this PR fixes:

N/A (direct request, no tracking issue)

Special notes for your reviewer:

  • Scope is testing/infra/clusters only — no operator/runtime code changes.
  • Verified live: K3s single/multi-node, agent-empty (servers schedulable), pre-existing-k3s reclaim, and host-gw (confirmed via direct pod-CIDR routes over the physical NIC with no flannel.1) on a same-LAN pair; EKS non-rotation proven by a three-step apply (adding a second GPU group left the first group's node group and EC2 instance unchanged); the destroy-time ~/.kube/config cleanup was exercised on a real cluster.
  • terraform fmt/validate pass on both modules.

Does this PR introduce a user-facing change?

NONE

Copilot AI review requested due to automatic review settings July 15, 2026 01:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors testing/infra/clusters to make test cluster provisioning more predictable and single-purpose by introducing a new K3s-over-SSH Terraform module and stabilizing EKS GPU node group addressing to prevent unintended rotations.

Changes:

  • Added testing/infra/clusters/k3s: installs/uninstalls K3s on SSH-reachable hosts (servers + optional agents), fetches and merges kubeconfig, and cleans up kubeconfig entries on destroy.
  • Updated testing/infra/clusters/eks: changed GPU node group input from positional lists to a name-keyed map for stable node group keys, and removed Helm/operator deployment so the module only provisions the cluster.
  • Added destroy-time kubeconfig cleanup for EKS and updated provider locks accordingly.

Reviewed changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
testing/infra/clusters/k3s/variables.tf Defines K3s module inputs (hosts, SSH, release, flannel backend) and validation.
testing/infra/clusters/k3s/terraform.tf Pins required providers for the K3s module.
testing/infra/clusters/k3s/output.tf Exposes kubeconfig/context and resolved host outputs for consumers.
testing/infra/clusters/k3s/main.tf Implements K3s install/join/uninstall and kubeconfig fetch/merge/cleanup logic.
testing/infra/clusters/k3s/.terraform.lock.hcl Locks provider versions/hashes for reproducible K3s module init.
testing/infra/clusters/k3s/.gitignore Prevents committing the generated standalone kubeconfig file.
testing/infra/clusters/eks/variables.tf Changes GPU node group input type to a map keyed by group name for stability.
testing/infra/clusters/eks/terraform.tf Removes Helm provider requirement; keeps only cluster provisioning providers.
testing/infra/clusters/eks/main.tf Updates GPU node group map iteration; removes Helm/operator deployment; adds kubeconfig cleanup on destroy.
testing/infra/clusters/eks/.terraform.lock.hcl Removes Helm provider lock entries to match provider requirements.
Files not reviewed (2)
  • testing/infra/clusters/eks/.terraform.lock.hcl: Generated file
  • testing/infra/clusters/k3s/.terraform.lock.hcl: Generated file

Comment thread testing/infra/clusters/k3s/variables.tf Outdated
Comment thread testing/infra/clusters/k3s/variables.tf
Comment thread testing/infra/clusters/k3s/variables.tf
Comment thread testing/infra/clusters/k3s/main.tf
Comment thread testing/infra/clusters/k3s/main.tf
Comment thread testing/infra/clusters/eks/main.tf Outdated
Copilot AI review requested due to automatic review settings July 15, 2026 01:24
@thxCode thxCode force-pushed the spec/testing-clusters-eks-and-k3s branch from 6178315 to 2cc4bed Compare July 15, 2026 01:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 10 changed files in this pull request and generated 3 comments.

Files not reviewed (2)
  • testing/infra/clusters/eks/.terraform.lock.hcl: Generated file
  • testing/infra/clusters/k3s/.terraform.lock.hcl: Generated file

Comment thread testing/infra/clusters/k3s/main.tf
Comment thread testing/infra/clusters/k3s/main.tf Outdated
Comment thread testing/infra/clusters/k3s/main.tf Outdated
thxCode added 2 commits July 15, 2026 09:38
- new testing/infra/clusters/k3s module: install/uninstall K3s on SSH-reachable hosts via remote-exec, driven by server/agent host lists (user@host, per-role SSH ports)
- first server bootstraps embedded etcd (--cluster-init); extra servers and agents join with a shared random_string token; an empty agent list leaves the servers schedulable
- reclaim each target host before installing (uninstall any pre-existing k3s) so a node with a prior or foreign deployment is redeployed cleanly instead of failing on stale etcd/token data
- fetch the kubeconfig, namespace its identifiers to a k3s-<host> context with anchored sed, and flatten-merge it into ~/.kube/config (chmod 600) via a unique mktemp; destroy strips that context/cluster/user
- release takes a k3s release tag (e.g. v1.34.9+k3s1) passed straight to INSTALL_K3S_VERSION; named release because Terraform reserves version
- flannel_backend selects the flannel backend (default vxlan; host-gw for faster same-L2 networking)
- reject duplicate server/agent hosts (each host keys a node) at plan time
- ssh_private_key defaults to ~/.ssh/id_ed25519 (the provisioner cannot auth RSA against OpenSSH 8.8+)
- expose context_name, server_hosts, agent_hosts, and kubeconfig_path outputs

Signed-off-by: thxCode <thxcode0824@gmail.com>
- key GPU node groups by name (map(list(string)) -> gpu-<name>) instead of positional list index, so adding or editing one entry no longer rotates the untouched node groups
- remove helm_release, the helm provider, var.image, and the gpustack_operator_image local so the module only provisions the cluster
- strip the cluster's context/cluster/user from ~/.kube/config on destroy via a self.triggers-only, on_failure=continue local-exec

Signed-off-by: thxCode <thxcode0824@gmail.com>
Copilot AI review requested due to automatic review settings July 15, 2026 01:39
@thxCode thxCode force-pushed the spec/testing-clusters-eks-and-k3s branch from 2cc4bed to 0cb53a2 Compare July 15, 2026 01:39
@thxCode thxCode merged commit 94edf6e into main Jul 15, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 10 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • testing/infra/clusters/eks/.terraform.lock.hcl: Generated file
  • testing/infra/clusters/k3s/.terraform.lock.hcl: Generated file

Comment on lines +199 to +201
raw="$(mktemp)"
merged=""
trap 'rm -f "$raw" "$merged"' EXIT
@thxCode thxCode deleted the spec/testing-clusters-eks-and-k3s branch July 15, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants