feat(k3s): per-pool nodePrep (cloud-init packages/runcmd) (E2)#146
Merged
Conversation
Surface E1's cloud-init packages/runcmd through the k3s Cluster spec as a
per-pool `nodePrep: {packages, runcmd}` block on the control-plane and each
worker pool, so a pool installs its own host prerequisites — e.g. open-iscsi
for a Longhorn storage pool.
Mirrors the A3 GPU-per-pool shape field-for-field: NodePrepSpec +
parseNodePrepSpec + NodePrepForNode(i, cpCount) + ApplyNodePrepToVMSpec,
wired into BOTH VM-build paths (operative create.go and the Plan mirror
cluster_plan.go) via the shared resources helper so nodes come out
identical. ApplyNodePrepToVMSpec writes into the existing cloudInit map,
preserving user/sshKeys/ipConfig. #NodePrep CUE def on both pools.
Makes F1 (Longhorn) usable — the tier that needs open-iscsi on nodes.
Tests: parse+resolve across the flat control-plane-then-workers ordering,
apply-into-cloudInit (nil/empty no-op, preserves siblings, creates map if
absent), and an operative GenerateDispatchRequests test asserting only the
target pool's VMs get the prereqs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
E2 — k3s node-pool node prep
Surfaces E1's cloud-init
packages/runcmdthrough the k3s Cluster spec as a per-poolnodePrepblock, so a worker pool installs its own host prerequisites — e.g.open-iscsifor a Longhorn storage pool. This is what makes F1 (Longhorn) usable.Mirrors the A3 GPU-per-pool pattern exactly
NodePrepSpeconControlPlaneSpec+WorkerSpecparseNodePrepSpec(untyped map → struct)NodePrepForNode(i, cpCount, spec)— resolves the pool for a node across the flat control-plane-then-workers orderingApplyNodePrepToVMSpec(vmSpec, np)— writespackages/runcmdinto the existingcloudInitmap (preservinguser/sshKeys/ipConfig); no-op when nil/empty#NodePrepCUE def referenced on both poolsBoth build paths stay in sync
Wired into both VM-build paths via the shared helper — the operative
pkg/k3s/cluster/create.goand the Plan mirrorinternal/controller/providers/k3s/cluster_plan.go— same as GPU (the K1 "keep these identical" debt; this change keeps them identical). No struct/signature changes, stdlib-only, so no module churn.Tests
nodeprep_test.go: parse +NodePrepForNoderesolution across the flat ordering;ApplyNodePrepToVMSpec(nil/empty no-op, preserves siblings, creates cloudInit if absent).TestGenerateDispatchRequests_NodePrep: drives the operative create path, asserts only the target pool's VMs carrycloudInit.packages/runcmd(CP + other workers untouched,userpreserved).Local CI: build,
go test ./...(+-raceon affected), gofmt, vet, staticcheck, golangci-lint (0 issues), modernize — root and the k3s plugin module — all green.