fix(kubernetes): apply the worker TalosConfigTemplate server-side in the kubernetes chart

On release-1.6 the kubernetes chart still renders a talos-reconcile Job
for every node group, and that Job applies the worker
TalosConfigTemplate client-side under a 256Mi memory limit. Once the
template exists, a client-side apply builds its merge patch from the
full OpenAPI document of the management cluster, which #4163 measured
above that limit on a cluster with a few hundred CRDs. Every chart
upgrade runs the Job again against the existing template, so kubectl
is OOMKilled and the Job crash-loops after each upgrade. On a v1.6.5
cluster upgraded from v1.6.4 its log ends with the KamajiControlPlane
patch and the container was OOMKilled.

The server-side apply from #4163 reached release-1.6 through #4575,
which changed the kubernetes-nodes chart only. On main the kubernetes
chart no longer renders worker pools (92b9785da), so this Job and this
fix exist on release-1.6 only.

This uses the same server-side apply with --force-conflicts as
kubernetes-nodes. The merge happens in the apiserver, so kubectl never
loads the schema, and --force-conflicts keeps the Job authoritative
over a template an earlier client-side apply created. The Role already
grants create and patch on talosconfigtemplates. The Job spec changes,
so its content-hash name moves and existing clusters get a new Job on
their next upgrade.

Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
This commit is contained in:
Yan Bondarenko committed 2026-10-19 18:15:15 +03:00
1 parent 908b107ab4
commit b983a5c34e
3 files changed
+80 -5

No files matched your search

@@ -321,7 +321,7 @@ spec:
# Apply the TalosConfigTemplate. ownerReference back to the KCP
# makes the standard Kubernetes garbage collector clean it up on
# release uninstall; Helm itself does not track this resource.
cat <<EOF | kubectl apply -f -
cat <<EOF | kubectl apply --server-side --force-conflicts -f -
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha3
kind: TalosConfigTemplate
metadata:
@@ -0,0 +1,75 @@
suite: worker TalosConfigTemplate is applied server-side
templates:
- templates/talos/talos-reconcile-job.yaml
release:
name: test-k8s
namespace: tenant-test
set:
_namespace:
etcd: etcd
ingress: nginx
host: example.com
_cluster:
cluster-domain: cozy.local
tests:
- it: applies the TalosConfigTemplate server-side
asserts:
- matchRegex:
path: spec.template.spec.containers[0].command[2]
pattern: 'kubectl apply --server-side --force-conflicts -f -'
documentSelector:
path: kind
value: Job
- it: never falls back to a client-side apply
asserts:
- notMatchRegex:
path: spec.template.spec.containers[0].command[2]
pattern: 'kubectl apply -f -'
documentSelector:
path: kind
value: Job
- it: applies server-side from the Job of every node group
set:
nodeGroups:
worker0:
minReplicas: 1
maxReplicas: 3
instanceType: u1.medium
diskSize: 20Gi
storageClass: ""
roles:
- ingress-nginx
resources: {}
gpus: []
kubelet: {}
worker1:
minReplicas: 0
maxReplicas: 5
instanceType: u1.medium
diskSize: 20Gi
storageClass: ""
roles: []
resources: {}
gpus: []
kubelet: {}
asserts:
- hasDocuments:
count: 8
- matchRegex:
path: spec.template.spec.containers[0].command[2]
pattern: 'kubectl apply --server-side --force-conflicts -f -'
documentSelector:
path: kind
value: Job
matchMany: true
- notMatchRegex:
path: spec.template.spec.containers[0].command[2]
pattern: 'kubectl apply -f -'
documentSelector:
path: kind
value: Job
matchMany: true
@@ -156,7 +156,7 @@ tests:
asserts:
- equal:
path: metadata.name
value: test-k8s-talos-reconcile-md0-16c1c9
value: test-k8s-talos-reconcile-md0-4916b0
documentSelector:
path: kind
value: Job
@@ -189,12 +189,12 @@ tests:
gpus:
- name: nvidia.com/GH200
asserts:
# Only gpus changed vs the case above, yet the suffix differs (a9dc0c vs
# 16c1c9) — the content hash tracks the rendered spec, and the TCT the Job
# Only gpus changed vs the case above, yet the suffix differs (63c431 vs
# 4916b0) — the content hash tracks the rendered spec, and the TCT the Job
# applies is what changed (GPU nodeLabels).
- equal:
path: metadata.name
value: test-k8s-talos-reconcile-md0-a9dc0c
value: test-k8s-talos-reconcile-md0-63c431
documentSelector:
path: kind
value: Job