Skip to content

Commit 141740f

Browse files
Merge pull request #259 from cozystack/fix/charts-talos-v114-contract
fix(charts): render the Talos v1.14 config contract
2 parents cfc5a95 + 0dd28fc commit 141740f

37 files changed

Lines changed: 2576 additions & 279 deletions

‎charts/cozystack/Chart.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ templateOptions:
1212
fileValues: []
1313
jsonValues: []
1414
literalValues: []
15-
talosVersion: "v1.12"
15+
talosVersion: "v1.14"
1616
withSecrets: "secrets.yaml"
17-
kubernetesVersion: "v1.34.3"
17+
kubernetesVersion: "v1.36.5"
1818
full: false
1919
applyOptions:
2020
preserve: false

‎charts/cozystack/templates/_helpers.tpl‎

Lines changed: 216 additions & 95 deletions
Large diffs are not rendered by default.

‎charts/cozystack/values.yaml‎

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,18 @@ floatingIP: ""
7777
# non-existent link and the cluster endpoint will be unreachable.
7878
# Example: vipLink: eth0.4000
7979
vipLink: ""
80-
image: "ghcr.io/cozystack/cozystack/talos:v1.12.6"
80+
image: "ghcr.io/cozystack/cozystack/talos:v1.14.2"
8181
podSubnets:
8282
- 10.244.0.0/16
8383
serviceSubnets:
8484
- 10.96.0.0/16
8585

86-
# Optional override for machine.kubelet.nodeIP.validSubnets and
87-
# cluster.etcd.advertisedSubnets. When left empty the chart derives
88-
# the value from the node's IPv4-default-gateway-bearing link at
89-
# render time (via talm.discovered.default_addresses_by_gateway), so
90-
# the generated machine config matches the node's actual network
86+
# Optional override for the kubelet node IP subnets
87+
# (machine.kubelet.nodeIP.validSubnets; KubeNodeConfig nodeIP.validSubnets
88+
# from Talos v1.14) and cluster.etcd.advertisedSubnets. When left empty
89+
# the chart derives the value from the node's IPv4-default-gateway-bearing
90+
# link at render time (via talm.discovered.default_addresses_by_gateway),
91+
# so the generated machine config matches the node's actual network
9192
# without any values.yaml edit. Set this only when you want to pin a
9293
# specific subnet — typically for multi-homed nodes where the
9394
# IPv4-default-gateway link is not the subnet you want kubelet/etcd
@@ -178,12 +179,15 @@ etcd:
178179
# - bar=baz
179180
extraKernelModules: []
180181

181-
# Extra kubelet args added to the preset's kubelet.extraConfig
182-
# (cpuManagerPolicy: static, maxPods: 512). Operator keys must be
183-
# DISJOINT from the built-in set; a collision fails the render with
184-
# a hint pointing at the offending key. Example:
182+
# Extra kubelet args added to the preset's built-in kubelet settings
183+
# (cpuManagerPolicy: static, maxPods: 512), which land in
184+
# machine.kubelet.extraConfig, or KubeletConfig config from Talos v1.14.
185+
# Operator keys must be DISJOINT from the built-in set; a collision
186+
# fails the render with a hint pointing at the offending key. Keys and
187+
# values follow KubeletConfiguration. Example:
185188
# extraKubeletExtraArgs:
186-
# feature-gates: "NodeSwap=true"
189+
# featureGates:
190+
# NodeSwap: true
187191
extraKubeletExtraArgs: {}
188192

189193
# Extra kernel sysctls added to machine.sysctls alongside the
@@ -232,7 +236,11 @@ timeServers: []
232236
# a key that collides with a preset built-in fails the render — for
233237
# controllerManager (bind-address / allocate-node-cidrs / cluster-cidr),
234238
# scheduler (bind-address), and apiServer (the oidc-* args, but only
235-
# when oidcIssuerUrl is set). Example:
239+
# when oidcIssuerUrl is set). From Talos v1.14 kube-apiserver takes no
240+
# authentication or authorization flags, so any oidc-*, anonymous-auth,
241+
# authentication-config or authorization-config/-mode/-webhook-* key
242+
# fails the render; oidcIssuerUrl becomes a KubeAuthenticationConfig
243+
# document instead. Example:
236244
# extraApiServerArgs: { max-requests-inflight: "2000" }
237245
extraApiServerArgs: {}
238246
extraControllerManagerArgs: {}

‎charts/generic/Chart.yaml‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ templateOptions:
1515
# Pin both: an empty key either renders what the node picks (with a warning)
1616
# or stops the render on newer contracts. The Kubernetes version is the
1717
# default of the pinned Talos line, so a fresh project lands on what that
18-
# line ships and a re-sync does not move the control plane. Replace it with
19-
# the version your cluster runs.
20-
talosVersion: "v1.13"
18+
# line ships. Replace it with the version your cluster runs.
19+
talosVersion: "v1.14"
2120
withSecrets: "secrets.yaml"
22-
kubernetesVersion: "v1.36.2"
21+
kubernetesVersion: "v1.37.0"
2322
full: false
2423
applyOptions:
2524
preserve: false

‎charts/generic/templates/_helpers.tpl‎

Lines changed: 86 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,16 @@
1010
{{- define "talos.config.machine.common" }}
1111
machine:
1212
type: {{ .MachineType }}
13+
{{- if not (include "talm.contract.kubedocs" .) }}
1314
kubelet:
1415
nodeIP:
1516
validSubnets:
16-
{{- if .Values.advertisedSubnets }}
17-
{{- toYaml .Values.advertisedSubnets | nindent 8 }}
18-
{{- else }}
19-
{{- /* Fall back to the subnet of the node's default-gateway-bearing
20-
link. cidrNetwork masks host bits so the emitted YAML is the
21-
canonical network form (192.168.201.0/24) rather than the
22-
host form (192.168.201.10/24). Dedupe after masking because
23-
a link with a secondary address in the same subnet would
24-
otherwise produce duplicate list entries. */ -}}
25-
{{- $addrs := fromJsonArray (include "talm.discovered.default_addresses_by_gateway" .) }}
26-
{{- if not $addrs }}
27-
{{- fail "values.yaml: `advertisedSubnets` was left empty and talm could not derive a default from discovery. No default-gateway-bearing link was found on the node. This field is a cluster-wide subnet selector fed to kubelet and etcd; `talm template` is invoked once per node and cannot merge per-node values into one cluster value. Either set advertisedSubnets explicitly in values.yaml, or ensure the node has a default route before running `talm template`." }}
28-
{{- end }}
29-
{{- $subnets := list }}
30-
{{- range $addrs }}
31-
{{- $subnets = append $subnets (. | cidrNetwork) }}
32-
{{- end }}
33-
{{- range uniq $subnets }}
34-
- {{ . }}
35-
{{- end }}
36-
{{- end }}
17+
{{- include "talm.advertised_subnets" (dict "root" . "indent" 8) }}
3718
{{- with .Values.extraKubeletExtraArgs }}
3819
extraConfig:
3920
{{- toYaml . | nindent 6 }}
4021
{{- end }}
22+
{{- end }}
4123
{{- with .Values.certSANs }}
4224
certSANs:
4325
{{- toYaml . | nindent 2 }}
@@ -85,6 +67,82 @@ machine:
8567
{{- end }}
8668
{{- end }}
8769

70+
{{- define "talos.config.cluster_name" -}}
71+
{{ include "talm.validate.dns1123subdomain" (dict "value" (.Values.clusterName | default .Chart.Name) "field" "clusterName") | quote }}
72+
{{- end }}
73+
74+
{{- define "talos.config.endpoint" -}}
75+
{{ required "values.yaml: `endpoint` must be set to the cluster control-plane URL (e.g. https://<vip>:6443). This field is cluster-wide: every node's kubelet and kube-proxy dials it, so it cannot be auto-derived from the current node's IP -- `talm template` runs once per node and has no way to reconcile per-node IPs into a single shared endpoint. For multi-node setups use a VIP or an external load balancer; for single-node clusters the node's routable IP works." .Values.endpoint | quote }}
76+
{{- end }}
77+
78+
{{- /* Cluster settings on contract v1.14+. Only etcd stays in v1alpha1;
79+
the rest are typed documents the engine merges into the ones the
80+
generator emits, so they carry only what this chart sets. */ -}}
81+
{{- define "talos.config.cluster.kubedocs" }}
82+
{{- if eq .MachineType "controlplane" }}
83+
84+
cluster:
85+
etcd:
86+
advertisedSubnets:
87+
{{- include "talm.advertised_subnets" (dict "root" . "indent" 6) }}
88+
{{- end }}
89+
---
90+
apiVersion: v1alpha1
91+
kind: KubeClusterConfig
92+
clusterName: {{ include "talos.config.cluster_name" . }}
93+
endpoint: {{ include "talos.config.endpoint" . }}
94+
---
95+
apiVersion: v1alpha1
96+
kind: KubeNodeConfig
97+
nodeIP:
98+
validSubnets:
99+
{{- include "talm.advertised_subnets" (dict "root" . "indent" 4) }}
100+
{{- with .Values.extraKubeletExtraArgs }}
101+
---
102+
apiVersion: v1alpha1
103+
kind: KubeletConfig
104+
config:
105+
{{- toYaml . | nindent 2 }}
106+
{{- end }}
107+
---
108+
apiVersion: v1alpha1
109+
kind: KubeNetworkConfig
110+
podSubnets:
111+
{{- toYaml .Values.podSubnets | nindent 2 }}
112+
serviceSubnets:
113+
{{- toYaml .Values.serviceSubnets | nindent 2 }}
114+
{{- if eq .MachineType "controlplane" }}
115+
{{- with .Values.extraControllerManagerArgs }}
116+
---
117+
apiVersion: v1alpha1
118+
kind: KubeControllerManagerConfig
119+
extraArgs:
120+
{{- include "talm.render.component_args" (dict "args" . "field" "extraControllerManagerArgs" "indent" 2) }}
121+
{{- end }}
122+
{{- with .Values.extraSchedulerArgs }}
123+
---
124+
apiVersion: v1alpha1
125+
kind: KubeSchedulerConfig
126+
extraArgs:
127+
{{- include "talm.render.component_args" (dict "args" . "field" "extraSchedulerArgs" "indent" 2) }}
128+
{{- end }}
129+
{{- include "talm.guard.apiserver_args_kubedocs" . }}
130+
{{- if or .Values.extraApiServerArgs .Values.certSANs }}
131+
---
132+
apiVersion: v1alpha1
133+
kind: KubeAPIServerConfig
134+
{{- with .Values.extraApiServerArgs }}
135+
extraArgs:
136+
{{- include "talm.render.component_args" (dict "args" . "field" "extraApiServerArgs" "indent" 2) }}
137+
{{- end }}
138+
{{- with .Values.certSANs }}
139+
certExtraSANs:
140+
{{- toYaml . | nindent 2 }}
141+
{{- end }}
142+
{{- end }}
143+
{{- end }}
144+
{{- end }}
145+
88146
{{- /* Shared cluster section */ -}}
89147
{{- define "talos.config.cluster" }}
90148

@@ -94,9 +152,9 @@ cluster:
94152
{{- toYaml .Values.podSubnets | nindent 6 }}
95153
serviceSubnets:
96154
{{- toYaml .Values.serviceSubnets | nindent 6 }}
97-
clusterName: {{ include "talm.validate.dns1123subdomain" (dict "value" (.Values.clusterName | default .Chart.Name) "field" "clusterName") | quote }}
155+
clusterName: {{ include "talos.config.cluster_name" . }}
98156
controlPlane:
99-
endpoint: {{ required "values.yaml: `endpoint` must be set to the cluster control-plane URL (e.g. https://<vip>:6443). This field is cluster-wide: every node's kubelet and kube-proxy dials it, so it cannot be auto-derived from the current node's IP -- `talm template` runs once per node and has no way to reconcile per-node IPs into a single shared endpoint. For multi-node setups use a VIP or an external load balancer; for single-node clusters the node's routable IP works." .Values.endpoint | quote }}
157+
endpoint: {{ include "talos.config.endpoint" . }}
100158
{{- if eq .MachineType "controlplane" }}
101159
{{- with .Values.extraControllerManagerArgs }}
102160
controllerManager:
@@ -124,23 +182,7 @@ cluster:
124182
{{- end }}
125183
etcd:
126184
advertisedSubnets:
127-
{{- if .Values.advertisedSubnets }}
128-
{{- toYaml .Values.advertisedSubnets | nindent 6 }}
129-
{{- else }}
130-
{{- /* Fall back to the subnet of the node's default-gateway-bearing
131-
link; cidrNetwork masks host bits to emit canonical network
132-
form. Dedupe handled the same way as validSubnets above.
133-
Empty discovery already errored via validSubnets' required()
134-
guard, so we reach this block only when at least one address
135-
was resolved. */ -}}
136-
{{- $subnets := list }}
137-
{{- range fromJsonArray (include "talm.discovered.default_addresses_by_gateway" .) }}
138-
{{- $subnets = append $subnets (. | cidrNetwork) }}
139-
{{- end }}
140-
{{- range uniq $subnets }}
141-
- {{ . }}
142-
{{- end }}
143-
{{- end }}
185+
{{- include "talm.advertised_subnets" (dict "root" . "indent" 6) }}
144186
{{- end }}
145187
{{- end }}
146188

@@ -291,7 +333,11 @@ cluster:
291333
{{- define "talos.config.multidoc" }}
292334
{{- include "talos.config.machine.common" . }}
293335

336+
{{- if include "talm.contract.kubedocs" . }}
337+
{{- include "talos.config.cluster.kubedocs" . }}
338+
{{- else }}
294339
{{- include "talos.config.cluster" . }}
340+
{{- end }}
295341
{{- include "talm.config.registries.multidoc" . }}
296342
{{- include "talos.config.network.multidoc" . }}
297343
{{- end }}

‎charts/generic/values.yaml‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ podSubnets:
7171
serviceSubnets:
7272
- 10.96.0.0/16
7373

74-
# Optional override for machine.kubelet.nodeIP.validSubnets and
75-
# cluster.etcd.advertisedSubnets. When left empty the chart derives
76-
# the value from the node's IPv4-default-gateway-bearing link at
77-
# render time (via talm.discovered.default_addresses_by_gateway), so
78-
# the generated machine config matches the node's actual network
74+
# Optional override for the kubelet node IP subnets
75+
# (machine.kubelet.nodeIP.validSubnets; KubeNodeConfig nodeIP.validSubnets
76+
# from Talos v1.14) and cluster.etcd.advertisedSubnets. When left empty
77+
# the chart derives the value from the node's IPv4-default-gateway-bearing
78+
# link at render time (via talm.discovered.default_addresses_by_gateway),
79+
# so the generated machine config matches the node's actual network
7980
# without any values.yaml edit. Set this only when you want to pin a
8081
# specific subnet — typically for multi-homed nodes where the
8182
# IPv4-default-gateway link is not the subnet you want kubelet/etcd
@@ -103,11 +104,15 @@ certSANs: []
103104
# - bar=baz
104105
extraKernelModules: []
105106

106-
# Kubelet command-line args, rendered as machine.kubelet.extraConfig.
107-
# Talos expects string values. Example:
107+
# Kubelet configuration (KubeletConfiguration fields, not command-line
108+
# flags), rendered as machine.kubelet.extraConfig
109+
# (KubeletConfig config from Talos v1.14).
110+
# Keys and values follow KubeletConfiguration: maxPods is a number,
111+
# feature gates go under featureGates. Example:
108112
# extraKubeletExtraArgs:
109-
# maxPods: "256"
110-
# feature-gates: "NodeSwap=true"
113+
# maxPods: 256
114+
# featureGates:
115+
# NodeSwap: true
111116
extraKubeletExtraArgs: {}
112117

113118
# Kernel sysctls, rendered as machine.sysctls. Values must be YAML

‎charts/talm/templates/_helpers.tpl‎

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,11 @@ busPath: {{ .spec.busPath }}
360360
are the only thing standing between a values typo and a component
361361
that either fails to start or starts with a nonsense flag, and six
362362
copies of them would drift. Expects a dict with "args" and "field"
363-
(the values.yaml key name, used in messages). */ -}}
363+
(the values.yaml key name, used in messages), and optionally "indent"
364+
(default 6, the v1alpha1 cluster.<component>.extraArgs depth). */ -}}
364365
{{- define "talm.render.component_args" }}
365366
{{- $field := .field }}
367+
{{- $indent := .indent | default 6 | int }}
366368
{{- range $k, $v := .args }}
367369
{{- if kindIs "invalid" $v }}
368370
{{- fail (printf "values.yaml: %s.%s has no value. A bare `key:` renders as the literal string \"<nil>\" onto the component command line; give it a value or drop the key." $field $k) }}
@@ -372,7 +374,52 @@ busPath: {{ .spec.busPath }}
372374
{{- if or (kindIs "map" $v) (kindIs "slice" $v) }}
373375
{{- fail (printf "values.yaml: %s.%s is a %s, but a component flag takes a single scalar value. Write it as the string the component expects." $field $k (kindOf $v)) }}
374376
{{- end }}
375-
{{ $k }}: {{ $v | toString | quote }}
377+
{{- printf "%s: %s" $k ($v | toString | quote) | nindent $indent }}
378+
{{- end }}
379+
{{- end }}
380+
381+
{{- /* Non-empty from contract v1.14, where Talos keeps the Kubernetes
382+
settings in typed documents (KubeClusterConfig, KubeletConfig,
383+
KubeNodeConfig, ...) and refuses the v1alpha1 fields next to them. */ -}}
384+
{{- define "talm.contract.kubedocs" -}}
385+
{{- if and .TalosVersion (not (semverCompare "<1.14.0-0" .TalosVersion)) }}true{{ end }}
386+
{{- end }}
387+
388+
{{- /* From contract v1.14 Talos refuses these kube-apiserver flags in
389+
KubeAPIServerConfig and takes them only as typed documents; fail at
390+
render rather than at apply. */ -}}
391+
{{- define "talm.guard.apiserver_args_kubedocs" }}
392+
{{- range $k, $_ := .Values.extraApiServerArgs }}
393+
{{- range list "oidc-" "anonymous-auth" "authentication-config" "authorization-config" "authorization-mode" "authorization-webhook-" }}
394+
{{- if hasPrefix . $k }}
395+
{{- fail (printf "values.yaml: extraApiServerArgs.%s is not accepted on Talos v1.14 and later, which configures kube-apiserver authentication and authorization through the KubeAuthenticationConfig and KubeAuthorizerConfig documents. Drop it from extraApiServerArgs and add that document as a per-node patch, or pin templateOptions.talosVersion to v1.13 or lower." $k) }}
396+
{{- end }}
397+
{{- end }}
398+
{{- end }}
399+
{{- end }}
400+
401+
{{- /* advertisedSubnets as YAML list items at .indent, falling back to the
402+
subnet of the node's default-gateway-bearing link. cidrNetwork masks
403+
host bits so the list holds the canonical network form
404+
(192.168.201.0/24, not 192.168.201.10/24); uniq drops the duplicate a
405+
secondary address in the same subnet would add. Expects a dict with
406+
"root" (the chart context) and "indent". */ -}}
407+
{{- define "talm.advertised_subnets" }}
408+
{{- $root := .root }}
409+
{{- if $root.Values.advertisedSubnets }}
410+
{{- toYaml $root.Values.advertisedSubnets | nindent .indent }}
411+
{{- else }}
412+
{{- $addrs := fromJsonArray (include "talm.discovered.default_addresses_by_gateway" $root) }}
413+
{{- if not $addrs }}
414+
{{- fail "values.yaml: `advertisedSubnets` was left empty and talm could not derive a default from discovery. No default-gateway-bearing link was found on the node. This field is a cluster-wide subnet selector fed to kubelet and etcd; `talm template` is invoked once per node and cannot merge per-node values into one cluster value. Either set advertisedSubnets explicitly in values.yaml, or ensure the node has a default route before running `talm template`." }}
415+
{{- end }}
416+
{{- $subnets := list }}
417+
{{- range $addrs }}
418+
{{- $subnets = append $subnets (. | cidrNetwork) }}
419+
{{- end }}
420+
{{- range uniq $subnets }}
421+
{{- printf "- %s" . | nindent $.indent }}
422+
{{- end }}
376423
{{- end }}
377424
{{- end }}
378425

‎docs/configuration/node-files.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ A node file can carry Talos config below its modeline (for example, a custom `ho
7373

7474
## Idempotent applies
7575

76-
Repeated `talm apply` runs against an already-configured node do not duplicate entries. Before the strategic merge runs, the engine prunes from the body every primitive-list entry the rendered template already carries (e.g. certSANs, nameservers, validSubnets). For object arrays the upstream patcher merges by identity (machine.network.interfaces by `interface:` or `deviceSelector:`, vlans by `vlanId:`, apiServer admissionControl by `name:`), the prune descends into matched pairs and dedupes the inner primitive lists too — so re-applying after `talm template -I` does not double interface addresses, vlan addresses, or admission-control exemption namespaces. For object arrays without an upstream identity merge (extraVolumes, kernel.modules, wireguard.peers, ...), body items that deep-equal a rendered counterpart are dropped, covering the dominant full-restate case. Fields tagged `merge:"replace"` upstream are passed through verbatim — pruning them would let the upstream replace silently drop the rendered entries on a partial edit. This covers v1alpha1 root paths `cluster.network.podSubnets`, `cluster.network.serviceSubnets`, `cluster.apiServer.auditPolicy`, and the typed `NetworkRuleConfig` paths `ingress` and `portSelector.ports`.
76+
Repeated `talm apply` runs against an already-configured node do not duplicate entries. Before the strategic merge runs, the engine prunes from the body every primitive-list entry the rendered template already carries (e.g. certSANs, nameservers, validSubnets). For object arrays the upstream patcher merges by identity (machine.network.interfaces by `interface:` or `deviceSelector:`, vlans by `vlanId:`, apiServer admissionControl by `name:`), the prune descends into matched pairs and dedupes the inner primitive lists too — so re-applying after `talm template -I` does not double interface addresses, vlan addresses, or admission-control exemption namespaces. For object arrays without an upstream identity merge (extraVolumes, kernel.modules, wireguard.peers, ...), body items that deep-equal a rendered counterpart are dropped, covering the dominant full-restate case. Fields tagged `merge:"replace"` upstream are passed through verbatim — pruning them would let the upstream replace silently drop the rendered entries on a partial edit. This covers v1alpha1 root paths `cluster.network.podSubnets`, `cluster.network.serviceSubnets`, `cluster.apiServer.auditPolicy`, the typed `NetworkRuleConfig` paths `ingress` and `portSelector.ports`, `advertise`, `importRoutes` and `neighbors` of `BGPInstanceConfig`, `overrides` of `CRIBaseRuntimeSpecConfig`, and from Talos v1.14 `podSubnets` and `serviceSubnets` of `KubeNetworkConfig`, `pod` of `KubeStaticPodConfig` and `configuration` of `KubeAuthenticationConfig`, `KubeAuditPolicyConfig` and `KubeCredentialProviderConfig`. The typed paths are matched per kind: `configuration` of `KubeAdmissionControlConfig` merges and is pruned as usual. Component `extraArgs` (kubelet, apiserver, controller-manager, scheduler, proxy, etcd, in v1alpha1 and in the typed documents) merge key by key and replace the whole value of each key the body sets, so the prune drops only keys the body restates exactly; a list-valued flag such as `feature-gates` edited in the node file keeps the rendered entries the body lists.
7777

7878
## What `talm template` does not do
7979

0 commit comments

Comments
 (0)