From b5e71bf8f7fdd8419a53a9092b4ee6b0039e735a Mon Sep 17 00:00:00 2001 From: Myasnikov Daniil Date: Thu, 12 Nov 2026 16:58:03 +0500 Subject: [PATCH] chore(kubernetes-nodes): drop split-era history from template and test comments Comments in the pool chart still explain it against the monolithic kubernetes chart, a "Phase 2b" migration, a render-parity gate and a tests/render-parity.sh that no longer exist, an Ubuntu+kubeadm worker, and a maxUnhealthy default of "0" that is "50%". The Makefile's update target claimed to copy the Talos support matrix, which is a literal in _helpers.tpl; it copies the Kubernetes version map. A reader of these comments takes them as the description of what the code relies on, so they now describe the code as it is. Only Helm comments are touched: the YAML comments inside the hashed machine config and machine template text stay as they are, since editing them would rename the TalosConfigTemplate or KubevirtMachineTemplate and roll every worker. Assisted-by: LLM Signed-off-by: Myasnikov Daniil --- packages/apps/kubernetes-nodes/Makefile | 17 +++++++------ .../kubernetes-nodes/templates/_helpers.tpl | 16 ++++++------- .../templates/_talosconfigtemplate.tpl | 2 +- .../kubernetes-nodes/templates/nodegroup.yaml | 24 +++++++++---------- .../tests/kubelet_reservation_test.yaml | 9 ++++--- .../tests/mhc_rendering_test.yaml | 2 -- .../tests/mhc_timeouts_test.yaml | 5 ++-- .../tests/pod_cpu_limit_test.yaml | 6 ++--- .../tests/pod_cpu_request_test.yaml | 6 ++--- .../tests/render_snapshot_test.yaml | 17 ++++++------- .../tests/talos_worker_config_test.yaml | 1 - 11 files changed, 44 insertions(+), 61 deletions(-) diff --git a/packages/apps/kubernetes-nodes/Makefile b/packages/apps/kubernetes-nodes/Makefile index 701d81eaa..9c3dcb3de 100644 --- a/packages/apps/kubernetes-nodes/Makefile +++ b/packages/apps/kubernetes-nodes/Makefile @@ -9,16 +9,15 @@ generate: cozyvalues-gen -m 'kubernetesnodes' -v values.yaml -s values.schema.json -r README.md -g ../../../api/apps/v1alpha1/kubernetesnodes/types.go ../../../hack/update-crd.sh -# Keep the worker-image inputs (Talos<->Kubernetes support matrix and the -# kubectl.tag used by the talos-reconcile Job) in lockstep with the parent -# kubernetes chart. They are copied, not symlinked, so `helm package` bundles -# them; run this after the parent chart's `make update`. +# Copy the Kubernetes version map (files/versions.yaml, minor -> patch release) +# and the kubectl.tag used by the talos-reconcile Job from the kubernetes +# chart, which owns both. They are copied, not symlinked, so `helm package` +# bundles them; run this after either changes there. # -# _talosconfigtemplate.tpl is not copied from anywhere: the parent chart no -# longer carries worker node pools, so this chart owns the worker machine -# config outright. It stays here because the TalosConfigTemplate it renders is -# content-hash named and both consumers in this chart - nodegroup.yaml, which -# writes bootstrap.configRef, and talos-reconcile-job.yaml, which creates the +# _talosconfigtemplate.tpl is not copied from anywhere: this chart owns the +# worker machine config. The TalosConfigTemplate it renders is content-hash +# named and both consumers in this chart - nodegroup.yaml, which writes +# bootstrap.configRef, and talos-reconcile-job.yaml, which creates the # object - have to hash the same bytes. update: cp ../kubernetes/files/versions.yaml files/versions.yaml diff --git a/packages/apps/kubernetes-nodes/templates/_helpers.tpl b/packages/apps/kubernetes-nodes/templates/_helpers.tpl index a727a1043..5e317f8e6 100644 --- a/packages/apps/kubernetes-nodes/templates/_helpers.tpl +++ b/packages/apps/kubernetes-nodes/templates/_helpers.tpl @@ -165,10 +165,9 @@ The pool attaches to the parent Kubernetes CR named .Values.cluster, whose HelmRelease (and therefore CAPI Cluster / KamajiControlPlane / KubevirtCluster and every worker object it owns) is `kubernetes-`. This chart does NOT use its own .Release.Name for CAPI wiring — the pool lives in a separate -HelmRelease from the control plane, so every reference that the monolithic -chart made through $.Release.Name is reconstructed here as kubernetes- -instead. Linkage is by name convention (mirrors vm-instance -> vm-disk), not -ownerReference or lookup-gated render. +HelmRelease from the control plane, so every reference to the cluster's objects +is built from kubernetes-. Linkage is by name convention (mirrors +vm-instance -> vm-disk), not ownerReference or lookup-gated render. */}} {{- define "kubernetes-nodes.clusterName" -}} {{- if not .Values.cluster -}} @@ -194,9 +193,9 @@ The node-group name for this pool, derived from the release name. A KubernetesNodes CR is named - and gets the release prefix `kubernetes-nodes-`, so the release name is `kubernetes-nodes--`. The group name is the suffix. Enforcing the `-` segment keeps -every rendered object named `kubernetes--` — byte-identical to -what the monolithic chart rendered for the same group — and prevents two -clusters in one namespace from colliding on a pool named e.g. `md0`. +every rendered object named `kubernetes--` — the names worker +objects adopted by migration 56 already carry — and prevents two clusters in +one namespace from colliding on a pool named e.g. `md0`. */}} {{- define "kubernetes-nodes.groupName" -}} {{- $prefix := printf "kubernetes-nodes-%s-" .Values.cluster -}} @@ -253,8 +252,7 @@ control plane is supported (up to n-3 upstream) and is the normal state during a rolling upgrade — the parent Kubernetes CR is bumped first, then each pool. A symmetric equality check would flip every pool of a cluster to render-failure the moment the parent is bumped, blocking all pool operations until each pool is -hand-edited, so the check is directional. The split removed the single `version` -that used to feed both control plane and workers. Looks up the parent +hand-edited, so the check is directional. Looks up the parent KamajiControlPlane (named like the reconstructed clusterName) and compares its spec.version minor against .Values.version. Skipped when the lookup is empty (helm template / unittest, or the parent not yet present) so it validates only diff --git a/packages/apps/kubernetes-nodes/templates/_talosconfigtemplate.tpl b/packages/apps/kubernetes-nodes/templates/_talosconfigtemplate.tpl index 0061d4d26..1f69cd704 100644 --- a/packages/apps/kubernetes-nodes/templates/_talosconfigtemplate.tpl +++ b/packages/apps/kubernetes-nodes/templates/_talosconfigtemplate.tpl @@ -69,7 +69,7 @@ {{- /* Management cluster DNS domain. Tenant Kubernetes workers run as KubeVirt VMs inside the management cluster's pod network and need to resolve management-cluster service short names ("..svc") - the same way an Ubuntu+kubeadm worker did via cloud-init DHCP. The + the same way a pod of the management cluster does. The kubevirt-csi NFS mount path is the load-bearing case: kubelet on the worker host calls `mount.nfs linstor-csi-nfs.cozy-linstor.svc` (no domain suffix), and without searchDomains in /etc/resolv.conf diff --git a/packages/apps/kubernetes-nodes/templates/nodegroup.yaml b/packages/apps/kubernetes-nodes/templates/nodegroup.yaml index 18ec0e16b..6f9d03987 100644 --- a/packages/apps/kubernetes-nodes/templates/nodegroup.yaml +++ b/packages/apps/kubernetes-nodes/templates/nodegroup.yaml @@ -1,17 +1,16 @@ {{- /* Worker node pool for a managed Kubernetes cluster. - This chart is the second half of the Kubernetes-app split (cozystack/community#8): - the control plane (Cluster / KamajiControlPlane / KubevirtCluster / PKI) lives in - the `kubernetes` chart, and each worker pool is a separate `kubernetes-nodes` - release. The pool objects (KubevirtMachineTemplate, MachineDeployment, - MachineHealthCheck, worker WorkloadMonitor) and the talos-reconcile Job that - produces the pool's TalosConfigTemplate are rendered here, wired to the parent - cluster `kubernetes-` by name convention (see _helpers.tpl). Every - reference the monolithic chart made through $.Release.Name is reconstructed here - as the parent clusterName so the objects are byte-identical to what the parent - rendered for the same group — the KubevirtMachineTemplate is content-hash-named, - so any drift would roll every live worker VM. + The control plane (Cluster / KamajiControlPlane / KubevirtCluster / PKI) lives + in the `kubernetes` chart, and each worker pool is a separate + `kubernetes-nodes` release. The pool objects (machine template, + MachineDeployment, MachineHealthCheck, worker WorkloadMonitor) and the + talos-reconcile Job that produces the pool's TalosConfigTemplate are rendered + here, wired to the parent cluster `kubernetes-` by name convention + (see _helpers.tpl). Every reference to the cluster is built from that + clusterName. Pools adopted by migration 56 keep running on objects of exactly + these names and this content: the machine template is content-hash-named, so + any drift in its text would roll every live worker VM. Talos -> Kubernetes support matrix, against the pool default. The pool can also reach a different Talos release through osImage.builtin.version / @@ -1066,8 +1065,7 @@ spec: {{- /* MHC spec.maxUnhealthy is an IntOrString. CAPI admission accepts a bare integer (0, 1, ...) or a percentage string ("0%", "50%"), but rejects a quoted plain integer ("0"). Quote only when the operator - supplied a percentage; otherwise render the value as a bare int so - the admission webhook is happy with the chart-default "0". */}} + supplied a percentage; otherwise render the value as a bare int. */}} {{- $maxUnhealthy := toString $.Values.maxUnhealthy }} {{- $muSource := "maxUnhealthy" }} {{- if hasSuffix "%" $maxUnhealthy }} diff --git a/packages/apps/kubernetes-nodes/tests/kubelet_reservation_test.yaml b/packages/apps/kubernetes-nodes/tests/kubelet_reservation_test.yaml index 57ae0b476..1974c97b2 100644 --- a/packages/apps/kubernetes-nodes/tests/kubelet_reservation_test.yaml +++ b/packages/apps/kubernetes-nodes/tests/kubelet_reservation_test.yaml @@ -1,10 +1,9 @@ suite: kubelet reservation validation -# The kubelet-reservation branch (quantity-format regexes, positive-value and -# eviction-threshold invariants) moved verbatim from the parent chart into -# nodegroup.yaml. These failure-path guards reject malformed input at render -# time before a broken machineconfig reaches a worker. Ported from the parent -# chart's kubelet_reservation_test. +# The kubelet-reservation branch of nodegroup.yaml (quantity-format regexes, +# positive-value and eviction-threshold invariants). These failure-path guards +# reject malformed input at render time before a broken machineconfig reaches +# a worker. templates: - templates/nodegroup.yaml diff --git a/packages/apps/kubernetes-nodes/tests/mhc_rendering_test.yaml b/packages/apps/kubernetes-nodes/tests/mhc_rendering_test.yaml index 92603df9b..50be9041f 100644 --- a/packages/apps/kubernetes-nodes/tests/mhc_rendering_test.yaml +++ b/packages/apps/kubernetes-nodes/tests/mhc_rendering_test.yaml @@ -4,8 +4,6 @@ suite: MachineHealthCheck maxUnhealthy int-vs-percent rendering # but rejects a bare numeric STRING ("0"): a percentage must be a quoted string # and a count must be an unquoted int. nodegroup.yaml renders it as # maxUnhealthy: {{ if hasSuffix "%" ... }}{{ . | quote }}{{ else }}{{ . | int }}{{ end }} -# Ported from the parent chart's mhc_rendering_test after the pool moved to -# kubernetes-nodes. templates: - templates/nodegroup.yaml diff --git a/packages/apps/kubernetes-nodes/tests/mhc_timeouts_test.yaml b/packages/apps/kubernetes-nodes/tests/mhc_timeouts_test.yaml index ecea4ec2e..31fa9e3f2 100644 --- a/packages/apps/kubernetes-nodes/tests/mhc_timeouts_test.yaml +++ b/packages/apps/kubernetes-nodes/tests/mhc_timeouts_test.yaml @@ -16,9 +16,8 @@ suite: MachineHealthCheck timeouts # # `nodeStartupTimeout` bounds the phase before any of that: it is the window a # Machine has to produce a Node at all, and the unhealthyConditions entries are -# evaluated only once one exists. Its default is pinned here because the parity -# gate compares this chart against its counterpart, so a default moved in both -# at once passes there and only fails on this assertion. +# evaluated only once one exists. Its default is pinned here because a moved +# default changes every pool that does not set the field. templates: - templates/nodegroup.yaml diff --git a/packages/apps/kubernetes-nodes/tests/pod_cpu_limit_test.yaml b/packages/apps/kubernetes-nodes/tests/pod_cpu_limit_test.yaml index d7fdb5bd9..c172ac15d 100644 --- a/packages/apps/kubernetes-nodes/tests/pod_cpu_limit_test.yaml +++ b/packages/apps/kubernetes-nodes/tests/pod_cpu_limit_test.yaml @@ -1,7 +1,6 @@ suite: worker pool pod CPU limit -# Mirror of the parent kubernetes chart's suite, on the pool-shaped values of -# this chart. `podCpuLimit` is the only knob that sets +# `podCpuLimit` is the only knob that sets # `domain.resources.limits.cpu` on a worker VM. KubeVirt otherwise derives that # limit from the guest vCPU count whenever the namespace carries a ResourceQuota # that limits CPU, and it stops deriving as soon as the VMI declares the limit @@ -79,8 +78,7 @@ tests: asserts: # Absent, not empty: the KubevirtMachineTemplate is content-hash named, so # a `cpu:` key rendered for a pool that asked for nothing would rename the - # template and roll every live worker VM of the pool on upgrade. The - # render-parity gate compares those bytes against the parent chart. + # template and roll every live worker VM of the pool on upgrade. - notExists: path: spec.template.spec.virtualMachineTemplate.spec.template.spec.domain.resources.limits.cpu - equal: diff --git a/packages/apps/kubernetes-nodes/tests/pod_cpu_request_test.yaml b/packages/apps/kubernetes-nodes/tests/pod_cpu_request_test.yaml index af5d71041..9f6bf801d 100644 --- a/packages/apps/kubernetes-nodes/tests/pod_cpu_request_test.yaml +++ b/packages/apps/kubernetes-nodes/tests/pod_cpu_request_test.yaml @@ -1,7 +1,6 @@ suite: worker pool pod CPU request -# Mirror of the parent kubernetes chart's suite, on the pool-shaped values of -# this chart. `podCpuRequest` is the only knob that sets +# `podCpuRequest` is the only knob that sets # `domain.resources.requests.cpu` on a worker VM, and it is the other half of # `podCpuLimit`: KubeVirt copies a declared CPU limit into the request when the # VM declares none, so without this field the ceiling and the scheduler @@ -100,8 +99,7 @@ tests: asserts: # Absent, not empty: the KubevirtMachineTemplate is content-hash named, so # a `cpu:` key rendered for a pool that asked for nothing would rename the - # template and roll every live worker VM of the pool on upgrade. The - # render-parity gate compares those bytes against the parent chart. + # template and roll every live worker VM of the pool on upgrade. - notExists: path: spec.template.spec.virtualMachineTemplate.spec.template.spec.domain.resources.requests.cpu - equal: diff --git a/packages/apps/kubernetes-nodes/tests/render_snapshot_test.yaml b/packages/apps/kubernetes-nodes/tests/render_snapshot_test.yaml index 4e51d0f93..5ac60b0f3 100644 --- a/packages/apps/kubernetes-nodes/tests/render_snapshot_test.yaml +++ b/packages/apps/kubernetes-nodes/tests/render_snapshot_test.yaml @@ -2,12 +2,9 @@ suite: worker node pool golden render snapshot # Freezes the full rendered pool (KubevirtMachineTemplate, MachineDeployment, # MachineHealthCheck, worker WorkloadMonitor) for a representative node group. -# In PR-2a this render was proven byte-identical to the monolithic kubernetes -# chart's output via tests/render-parity.sh; PR-2b removed the pool from the -# parent, so cross-chart parity can no longer run. This snapshot takes over as -# the drift guard: any change to the rendered pool objects (which would rename -# the content-hashed KubevirtMachineTemplate and churn live worker VMs on -# upgrade) fails here until the snapshot is regenerated deliberately with +# It is the drift guard for those objects: any change to them (which would +# rename the content-hashed KubevirtMachineTemplate and churn live worker VMs +# on upgrade) fails here until the snapshot is regenerated deliberately with # `helm unittest -u`. # # Coverage note: every case sets instanceType: "" with explicit resources, @@ -44,10 +41,10 @@ tests: asserts: - matchSnapshot: {} - # GPU and kubelet-override branches live on in nodegroup.yaml after the split - # and are content-hash inputs to the KubevirtMachineTemplate; pin them too so - # a change to either branch that would rename the KMT (and roll live GPU or - # kubelet-tuned worker VMs) fails here. Value sets mirror the PR-2a parity gate. + # The GPU and kubelet-override branches of nodegroup.yaml are content-hash + # inputs to the KubevirtMachineTemplate; pin them too so a change to either + # branch that would rename the KMT (and roll live GPU or kubelet-tuned worker + # VMs) fails here. - it: matches the golden render of a GPU pool set: roles: [] diff --git a/packages/apps/kubernetes-nodes/tests/talos_worker_config_test.yaml b/packages/apps/kubernetes-nodes/tests/talos_worker_config_test.yaml index 10bff88f8..bcc387dd6 100644 --- a/packages/apps/kubernetes-nodes/tests/talos_worker_config_test.yaml +++ b/packages/apps/kubernetes-nodes/tests/talos_worker_config_test.yaml @@ -7,7 +7,6 @@ suite: Talos worker machineconfig (GPU labels + kubelet reservations) # - GPU pools must inject nodeLabels gpu=on so HAMi's device plugin # (nodeSelector gpu=on) schedules and advertises nvidia.com/gpu; # - kubelet reservation overrides must reach the machineconfig kubelet config. -# Ported from the parent chart's gpu_node_labels_test / kubelet_reservation_test. templates: - templates/talos-reconcile-job.yaml