-
Notifications
You must be signed in to change notification settings - Fork 23
feat(config): migrate to Talos v1.12 multi-document config format #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
719218e
dd1ede9
08e93d3
7f9957b
cac8dd9
463bfb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,13 @@ | ||
| {{- define "talos.config" }} | ||
| {{- if and .TalosVersion (not (semverCompare "<1.12.0-0" .TalosVersion)) }} | ||
| {{- include "talos.config.multidoc" . }} | ||
| {{- else }} | ||
| {{- include "talos.config.legacy" . }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| {{- /* Shared machine section: type, nodeLabels (controlplane), kubelet, sysctls, kernel, certSANs, files, install */ -}} | ||
| {{- define "talos.config.machine.common" }} | ||
| machine: | ||
| {{- if eq .MachineType "controlplane" }} | ||
| nodeLabels: | ||
|
|
@@ -14,8 +23,8 @@ machine: | |
| cpuManagerPolicy: static | ||
| maxPods: 512 | ||
| sysctls: | ||
| {{- with .Values.nr_hugepages }} | ||
| vm.nr_hugepages: {{ .Values.nr_hugepages | quote }} | ||
| {{- with $.Values.nr_hugepages }} | ||
| vm.nr_hugepages: {{ . | quote }} | ||
| {{- end }} | ||
| net.ipv4.neigh.default.gc_thresh1: "4096" | ||
| net.ipv4.neigh.default.gc_thresh2: "8192" | ||
|
|
@@ -35,11 +44,6 @@ machine: | |
| {{- with .Values.certSANs }} | ||
| {{- toYaml . | nindent 2 }} | ||
| {{- end }} | ||
| registries: | ||
| mirrors: | ||
| docker.io: | ||
| endpoints: | ||
| - https://mirror.gcr.io | ||
| files: | ||
| - content: | | ||
| [plugins] | ||
|
|
@@ -66,53 +70,10 @@ machine: | |
| {{- end }} | ||
| {{- (include "talm.discovered.disks_info" .) | nindent 4 }} | ||
| disk: {{ include "talm.discovered.system_disk_name" . | quote }} | ||
| network: | ||
| hostname: {{ include "talm.discovered.hostname" . | quote }} | ||
| nameservers: {{ include "talm.discovered.default_resolvers" . }} | ||
| {{- (include "talm.discovered.physical_links_info" .) | nindent 4 }} | ||
| interfaces: | ||
| {{- $existingInterfacesConfiguration := include "talm.discovered.existing_interfaces_configuration" . }} | ||
| {{- if $existingInterfacesConfiguration }} | ||
| {{- $existingInterfacesConfiguration | nindent 4 }} | ||
| {{- else }} | ||
| {{- $defaultLinkName := include "talm.discovered.default_link_name_by_gateway" . }} | ||
| {{- $isVlan := include "talm.discovered.is_vlan" $defaultLinkName }} | ||
| {{- $parentLinkName := "" }} | ||
| {{- if $isVlan }} | ||
| {{- $parentLinkName = include "talm.discovered.parent_link_name" $defaultLinkName }} | ||
| {{- end }} | ||
| {{- $interfaceName := $defaultLinkName }} | ||
| {{- if and $isVlan $parentLinkName }} | ||
| {{- $interfaceName = $parentLinkName }} | ||
| {{- end }} | ||
| - interface: {{ $interfaceName }} | ||
| {{- $bondConfig := include "talm.discovered.bond_config" $interfaceName }} | ||
| {{- if $bondConfig }} | ||
| {{- $bondConfig | nindent 6 }} | ||
| {{- end }} | ||
| {{- if $isVlan }} | ||
| vlans: | ||
| - vlanId: {{ include "talm.discovered.vlan_id" $defaultLinkName }} | ||
| addresses: {{ include "talm.discovered.default_addresses_by_gateway" . }} | ||
| routes: | ||
| - network: 0.0.0.0/0 | ||
| gateway: {{ include "talm.discovered.default_gateway" . }} | ||
| {{- if and .Values.floatingIP (eq .MachineType "controlplane") }} | ||
| vip: | ||
| ip: {{ .Values.floatingIP }} | ||
| {{- end }} | ||
| {{- else }} | ||
| addresses: {{ include "talm.discovered.default_addresses_by_gateway" . }} | ||
| routes: | ||
| - network: 0.0.0.0/0 | ||
| gateway: {{ include "talm.discovered.default_gateway" . }} | ||
| {{- if and .Values.floatingIP (eq .MachineType "controlplane") }} | ||
| vip: | ||
| ip: {{ .Values.floatingIP }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| {{- /* Shared cluster section */ -}} | ||
| {{- define "talos.config.cluster" }} | ||
| cluster: | ||
| network: | ||
| cni: | ||
|
|
@@ -161,3 +122,189 @@ cluster: | |
| {{- toYaml .Values.advertisedSubnets | nindent 6 }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| {{- /* Shared network document generation for v1.12+ multi-doc format */ -}} | ||
| {{- define "talos.config.network.multidoc" }} | ||
| {{- /* Multi-doc format always reconstructs network config from discovery resources. | ||
| existing_interfaces_configuration is not used here because v1.12 nodes store | ||
| network config in separate documents (LinkConfig, BondConfig, etc.), not in | ||
| the legacy machine.network.interfaces field. */ -}} | ||
| {{- (include "talm.discovered.physical_links_info" .) }} | ||
| --- | ||
| apiVersion: v1alpha1 | ||
| kind: HostnameConfig | ||
| hostname: {{ include "talm.discovered.hostname" . | quote }} | ||
| --- | ||
| apiVersion: v1alpha1 | ||
| kind: ResolverConfig | ||
| nameservers: | ||
| {{- $resolvers := include "talm.discovered.default_resolvers" . }} | ||
| {{- if $resolvers }} | ||
| {{- range fromJsonArray $resolvers }} | ||
| - address: {{ . | quote }} | ||
| {{- end }} | ||
| {{- else }} | ||
| [] | ||
| {{- end }} | ||
|
Comment on lines
+140
to
+148
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Talos v1.12+, the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current format is correct per the Go type definitions.
Source: The official test data ( nameservers:
- address: 10.0.0.1
- address: 2001:4860:4860::8888
Comment on lines
+140
to
+148
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor edge case: empty nameservers output. If nameservers:This is consistent with the generic template and likely acceptable, but verify Talos tolerates an empty 🤖 Prompt for AI Agents |
||
| {{- $defaultLinkName := include "talm.discovered.default_link_name_by_gateway" . }} | ||
| {{- $isVlan := include "talm.discovered.is_vlan" $defaultLinkName }} | ||
| {{- $parentLinkName := "" }} | ||
| {{- if $isVlan }} | ||
| {{- $parentLinkName = include "talm.discovered.parent_link_name" $defaultLinkName }} | ||
| {{- end }} | ||
| {{- $interfaceName := $defaultLinkName }} | ||
| {{- if and $isVlan $parentLinkName }} | ||
| {{- $interfaceName = $parentLinkName }} | ||
| {{- end }} | ||
| {{- $isBondInterface := include "talm.discovered.is_bond" $interfaceName }} | ||
| {{- if $isBondInterface }} | ||
| {{- $link := lookup "links" "" $interfaceName }} | ||
| {{- if $link }} | ||
| {{- $bondMaster := $link.spec.bondMaster }} | ||
| {{- $slaves := fromJsonArray (include "talm.discovered.bond_slaves" $link.spec.index) }} | ||
| --- | ||
| apiVersion: v1alpha1 | ||
| kind: BondConfig | ||
| name: {{ $interfaceName }} | ||
| links: | ||
| {{- range $slaves }} | ||
| - {{ . }} | ||
| {{- end }} | ||
| bondMode: {{ $bondMaster.mode }} | ||
| {{- if $bondMaster.xmitHashPolicy }} | ||
| xmitHashPolicy: {{ $bondMaster.xmitHashPolicy }} | ||
| {{- end }} | ||
| {{- if $bondMaster.lacpRate }} | ||
| lacpRate: {{ $bondMaster.lacpRate }} | ||
| {{- end }} | ||
| {{- if $bondMaster.miimon }} | ||
| miimon: {{ $bondMaster.miimon }} | ||
| {{- end }} | ||
| {{- if $bondMaster.updelay }} | ||
| updelay: {{ $bondMaster.updelay }} | ||
| {{- end }} | ||
| {{- if $bondMaster.downdelay }} | ||
| downdelay: {{ $bondMaster.downdelay }} | ||
| {{- end }} | ||
| {{- if not $isVlan }} | ||
| addresses: | ||
| {{- range fromJsonArray (include "talm.discovered.default_addresses_by_gateway" .) }} | ||
| - address: {{ . }} | ||
| {{- end }} | ||
| routes: | ||
| - gateway: {{ include "talm.discovered.default_gateway" . }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
Comment on lines
+160
to
+197
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are several schema and safety issues in the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Schema claims are incorrect, but the lookup safety point is valid.
Lookup safety — |
||
| {{- end }} | ||
| {{- if $isVlan }} | ||
| --- | ||
| apiVersion: v1alpha1 | ||
| kind: VLANConfig | ||
| name: {{ $defaultLinkName }} | ||
| vlanID: {{ include "talm.discovered.vlan_id" $defaultLinkName }} | ||
| parent: {{ $interfaceName }} | ||
| addresses: | ||
| {{- range fromJsonArray (include "talm.discovered.default_addresses_by_gateway" .) }} | ||
| - address: {{ . }} | ||
| {{- end }} | ||
| routes: | ||
| - gateway: {{ include "talm.discovered.default_gateway" . }} | ||
|
Comment on lines
+201
to
+211
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All three claims are incorrect.
|
||
| {{- else if not $isBondInterface }} | ||
| --- | ||
| apiVersion: v1alpha1 | ||
| kind: LinkConfig | ||
| name: {{ $interfaceName }} | ||
| addresses: | ||
| {{- range fromJsonArray (include "talm.discovered.default_addresses_by_gateway" .) }} | ||
| - address: {{ . }} | ||
| {{- end }} | ||
| routes: | ||
| - gateway: {{ include "talm.discovered.default_gateway" . }} | ||
|
Comment on lines
+215
to
+222
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both claims are incorrect.
|
||
| {{- end }} | ||
| {{- $vipLinkName := $interfaceName }} | ||
| {{- if $isVlan }} | ||
| {{- $vipLinkName = $defaultLinkName }} | ||
| {{- end }} | ||
| {{- if and .Values.floatingIP (eq .MachineType "controlplane") }} | ||
| --- | ||
| apiVersion: v1alpha1 | ||
| kind: Layer2VIPConfig | ||
| name: {{ .Values.floatingIP | quote }} | ||
| link: {{ $vipLinkName }} | ||
| {{- end }} | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| {{- end }} | ||
|
|
||
| {{- /* Shared legacy network section for machine.network */ -}} | ||
| {{- define "talos.config.network.legacy" }} | ||
| network: | ||
| hostname: {{ include "talm.discovered.hostname" . | quote }} | ||
| nameservers: {{ include "talm.discovered.default_resolvers" . }} | ||
| {{- (include "talm.discovered.physical_links_info" .) | nindent 4 }} | ||
| interfaces: | ||
| {{- $existingInterfacesConfiguration := include "talm.discovered.existing_interfaces_configuration" . }} | ||
| {{- if $existingInterfacesConfiguration }} | ||
| {{- $existingInterfacesConfiguration | nindent 4 }} | ||
| {{- else }} | ||
| {{- $defaultLinkName := include "talm.discovered.default_link_name_by_gateway" . }} | ||
| {{- $isVlan := include "talm.discovered.is_vlan" $defaultLinkName }} | ||
| {{- $parentLinkName := "" }} | ||
| {{- if $isVlan }} | ||
| {{- $parentLinkName = include "talm.discovered.parent_link_name" $defaultLinkName }} | ||
| {{- end }} | ||
| {{- $interfaceName := $defaultLinkName }} | ||
| {{- if and $isVlan $parentLinkName }} | ||
| {{- $interfaceName = $parentLinkName }} | ||
| {{- end }} | ||
| - interface: {{ $interfaceName }} | ||
| {{- $bondConfig := include "talm.discovered.bond_config" $interfaceName }} | ||
| {{- if $bondConfig }} | ||
| {{- $bondConfig | nindent 6 }} | ||
| {{- end }} | ||
| {{- if $isVlan }} | ||
| vlans: | ||
| - vlanId: {{ include "talm.discovered.vlan_id" $defaultLinkName }} | ||
| addresses: {{ include "talm.discovered.default_addresses_by_gateway" . }} | ||
| routes: | ||
| - network: 0.0.0.0/0 | ||
| gateway: {{ include "talm.discovered.default_gateway" . }} | ||
| {{- if and .Values.floatingIP (eq .MachineType "controlplane") }} | ||
| vip: | ||
| ip: {{ .Values.floatingIP }} | ||
| {{- end }} | ||
| {{- else }} | ||
| addresses: {{ include "talm.discovered.default_addresses_by_gateway" . }} | ||
| routes: | ||
| - network: 0.0.0.0/0 | ||
| gateway: {{ include "talm.discovered.default_gateway" . }} | ||
| {{- if and .Values.floatingIP (eq .MachineType "controlplane") }} | ||
| vip: | ||
| ip: {{ .Values.floatingIP }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| {{- define "talos.config.legacy" }} | ||
| {{- include "talos.config.machine.common" . }} | ||
| registries: | ||
| mirrors: | ||
| docker.io: | ||
| endpoints: | ||
| - https://mirror.gcr.io | ||
| {{- include "talos.config.network.legacy" . }} | ||
|
|
||
| {{- include "talos.config.cluster" . }} | ||
| {{- end }} | ||
|
|
||
| {{- define "talos.config.multidoc" }} | ||
| {{- include "talos.config.machine.common" . }} | ||
|
|
||
| {{- include "talos.config.cluster" . }} | ||
| --- | ||
| apiVersion: v1alpha1 | ||
| kind: RegistryMirrorConfig | ||
| name: docker.io | ||
| endpoints: | ||
| - url: https://mirror.gcr.io | ||
|
Comment on lines
+307
to
+308
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect. Endpoints are objects, not strings.
Endpoints must be objects because they support endpoints:
- url: https://my-private-registry.local:5000
- url: http://my-harbor/v2/registry-k8s.io/
overridePath: true |
||
| {{- include "talos.config.network.multidoc" . }} | ||
| {{- end }} | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve
existing_interfaces_configurationin the multi-doc branch.The legacy path consumes
talm.discovered.existing_interfaces_configuration, but the v1.12 path ignores it and always rebuilds from the default-route interface. That silently drops any non-default interface state as soon asTalosVersionflips to v1.12+. Please translate that helper output into named docs here, or fail fast when it is present.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentional.
talm.discovered.existing_interfaces_configurationemits a legacymachine.network.interfacesYAML fragment, which has no safe 1:1 translation to the v1.12 multi-doc resources (LinkConfig / BondConfig / VLANConfig / Layer2VIPConfig). Rather than silently producing a partial or incorrect translation, the multidoc path rebuilds the required documents from the discovery resources directly; the comment at the top oftalos.config.network.multidocdocuments this. Users who rely on custom legacy interface state should keepmachine.talosVersiononv1.11.xuntil they migrate their overrides to the new resources.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lexfrei, understood — that's a sound design rationale. Silently emitting a partial or incorrectly translated fragment would be far more dangerous than a clean rebuild from discovery resources, and the existing comment in the template documents the deliberate omission clearly. I'll note this for future reviews.(ʕ •ᴥ•ʔ)≡
✏️ Learnings added
🧠 Learnings used