Skip to content

Commit 5f902a1

Browse files
committed
fix(charts): allow vipLink override for Layer2VIPConfig.link
Operators occasionally need the floating VIP pinned to a link that does not yet exist on the live system at first apply: typically a VLAN sub-interface that the same template is about to bring up. Without an override, the chart derived vipLink from discovery, saw only the physical NIC, and pinned the VIP there; once the VLAN came up the VIP stayed on the bare-metal NIC, and Layer2VIPConfig described the wrong link. Add an opt-in .Values.vipLink override in both cozystack and generic charts. When set, Layer2VIPConfig is emitted unconditionally (with the operator-chosen link), even on a totally fresh node where discovery has not yet resolved a default-gateway link. The discovery-derived block below skips its own Layer2VIPConfig when vipLink is set, so the chart never emits duplicate documents. Documentation in values.yaml and README is explicit about what the chart does and does not do: the chart pins Layer2VIPConfig.link, the operator is responsible for ensuring the link itself comes up (typically by adding a LinkConfig or VLANConfig for that link to the per-node body overlay). If no such document brings vipLink up, Layer2VIPConfig will dangle on a non-existent link and the cluster endpoint will be unreachable. Surface floatingIP in charts/generic/values.yaml alongside vipLink so both options have the same explanatory comment block in both presets. Test coverage pins: - override path emits Layer2VIPConfig with the operator-chosen link and skips discovery's Layer2VIPConfig entirely - override path emits even on a fresh-node lookup with no resolved default-gateway link - override does not auto-emit a LinkConfig/VLANConfig for the override link (the documented operator-responsibility contract) - discovery-derived path remains the default when vipLink is unset Assisted-By: Claude <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 6138b11 commit 5f902a1

5 files changed

Lines changed: 97 additions & 3 deletions

File tree

‎README.md‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,17 @@ of silently embedding a placeholder. For cozystack VIP setups set
7777
`endpoint` and `floatingIP` together (same IP, single shared VIP);
7878
for single-node clusters use that node's routable IP and leave
7979
`floatingIP` blank; for multi-node with an external load balancer
80-
use the LB URL and leave `floatingIP` blank. Subnet-selector fields
80+
use the LB URL and leave `floatingIP` blank. When the VIP must sit
81+
on a link that does not yet exist on the live system at first apply
82+
(typically a VLAN sub-interface), set `vipLink` to that link name —
83+
the chart pins `Layer2VIPConfig.link` to it instead of the default-
84+
gateway link that discovery would otherwise pick, and emits the
85+
document even on a totally fresh node where no default-gateway link
86+
has been discovered yet. The chart does not auto-emit a `LinkConfig`
87+
or `VLANConfig` for the override link; the operator is responsible
88+
for ensuring the link comes up, typically by adding a `LinkConfig`
89+
or `VLANConfig` for that link to the per-node body overlay alongside
90+
`vipLink`. Subnet-selector fields
8191
(`kubelet.validSubnets`, `etcd.advertisedSubnets`) are derived
8292
automatically from the node's default-gateway-bearing link, so no
8393
override is needed unless you have a multi-homed node that requires

‎charts/cozystack/templates/_helpers.tpl‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,19 @@ nameservers:
182182
{{- else }}
183183
[]
184184
{{- end }}
185+
{{- /* Operator-declared vipLink override: emit Layer2VIPConfig
186+
regardless of discovery state. Useful when the target link
187+
does not yet exist on the live system at first apply (typical
188+
case: a VLAN sub-interface this template is about to bring up).
189+
The discovery-derived block below skips its own Layer2VIPConfig
190+
when this branch fires, so we never emit duplicates. */}}
191+
{{- if and .Values.floatingIP .Values.vipLink (eq .MachineType "controlplane") }}
192+
---
193+
apiVersion: v1alpha1
194+
kind: Layer2VIPConfig
195+
name: {{ .Values.floatingIP | quote }}
196+
link: {{ .Values.vipLink }}
197+
{{- end }}
185198
{{- $defaultLinkName := include "talm.discovered.default_link_name_by_gateway" . }}
186199
{{- if $defaultLinkName }}
187200
{{- $isVlan := include "talm.discovered.is_vlan" $defaultLinkName }}
@@ -258,11 +271,15 @@ addresses:
258271
routes:
259272
- gateway: {{ include "talm.discovered.default_gateway" . }}
260273
{{- end }}
274+
{{- /* Discovery-derived Layer2VIPConfig: skipped when the operator
275+
has set .Values.vipLink, since the override-path block above
276+
has already emitted the document with the operator's chosen
277+
link. */}}
278+
{{- if and .Values.floatingIP (not .Values.vipLink) (eq .MachineType "controlplane") }}
261279
{{- $vipLinkName := $interfaceName }}
262280
{{- if $isVlan }}
263281
{{- $vipLinkName = $defaultLinkName }}
264282
{{- end }}
265-
{{- if and .Values.floatingIP (eq .MachineType "controlplane") }}
266283
---
267284
apiVersion: v1alpha1
268285
kind: Layer2VIPConfig

‎charts/cozystack/values.yaml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@ clusterDomain: cozy.local
2929
# Single-node clusters and external-LB topologies leave it blank.
3030
# Example: floatingIP: 192.168.0.1
3131
floatingIP: ""
32+
33+
# Optional override for the link Layer2VIPConfig is pinned to. When
34+
# left empty the chart picks the default-gateway-bearing link the
35+
# node already has (the VLAN sub-interface if one carries the
36+
# default route, otherwise the physical NIC). Set this when the
37+
# target link does not yet exist on the live system at first apply
38+
# -- typically a VLAN sub-interface that the same template is about
39+
# to bring up. Without an override the chart would derive the link
40+
# from discovery on the bare-metal NIC, pin the VIP there, and the
41+
# VIP would land on the wrong link once the VLAN comes up.
42+
# When set, Layer2VIPConfig is emitted unconditionally, even on a
43+
# totally fresh node where discovery has not yet resolved a default-
44+
# gateway link. The chart does NOT auto-emit a LinkConfig/VLANConfig
45+
# for the override link; the operator is responsible for ensuring
46+
# the link comes up — typically by adding a LinkConfig or VLANConfig
47+
# document for that link to the per-node body overlay. If no such
48+
# document brings vipLink up, Layer2VIPConfig will dangle on a
49+
# non-existent link and the cluster endpoint will be unreachable.
50+
# Example: vipLink: eth0.4000
51+
vipLink: ""
3252
image: "ghcr.io/cozystack/cozystack/talos:v1.12.6"
3353
podSubnets:
3454
- 10.244.0.0/16

‎charts/generic/templates/_helpers.tpl‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@ nameservers:
105105
{{- else }}
106106
[]
107107
{{- end }}
108+
{{- /* Operator-declared vipLink override: emit Layer2VIPConfig
109+
regardless of discovery state. Useful when the target link
110+
does not yet exist on the live system at first apply (typical
111+
case: a VLAN sub-interface this template is about to bring up).
112+
The discovery-derived block below skips its own Layer2VIPConfig
113+
when this branch fires, so we never emit duplicates. */}}
114+
{{- if and .Values.floatingIP .Values.vipLink (eq .MachineType "controlplane") }}
115+
---
116+
apiVersion: v1alpha1
117+
kind: Layer2VIPConfig
118+
name: {{ .Values.floatingIP | quote }}
119+
link: {{ .Values.vipLink }}
120+
{{- end }}
108121
{{- $defaultLinkName := include "talm.discovered.default_link_name_by_gateway" . }}
109122
{{- if $defaultLinkName }}
110123
{{- $isVlan := include "talm.discovered.is_vlan" $defaultLinkName }}
@@ -181,11 +194,15 @@ addresses:
181194
routes:
182195
- gateway: {{ include "talm.discovered.default_gateway" . }}
183196
{{- end }}
197+
{{- /* Discovery-derived Layer2VIPConfig: skipped when the operator
198+
has set .Values.vipLink, since the override-path block above
199+
has already emitted the document with the operator's chosen
200+
link. */}}
201+
{{- if and .Values.floatingIP (not .Values.vipLink) (eq .MachineType "controlplane") }}
184202
{{- $vipLinkName := $interfaceName }}
185203
{{- if $isVlan }}
186204
{{- $vipLinkName = $defaultLinkName }}
187205
{{- end }}
188-
{{- if and .Values.floatingIP (eq .MachineType "controlplane") }}
189206
---
190207
apiVersion: v1alpha1
191208
kind: Layer2VIPConfig

‎charts/generic/values.yaml‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,36 @@
88
# Example: endpoint: "https://192.168.0.1:6443"
99
endpoint: ""
1010

11+
# Layer-2 VIP for multi-node setups. When set, the chart emits a
12+
# Layer2VIPConfig document pinning this IP as a floating address on
13+
# the node's primary link. MUST equal the host portion of `endpoint`
14+
# above, otherwise the cluster dials an IP that no node actually
15+
# claims. Blank by default so the shipped value never silently embeds
16+
# a wrong VIP — fill in only if you want a VIP. Single-node clusters
17+
# and external-LB topologies leave it blank.
18+
# Example: floatingIP: 192.168.0.1
19+
floatingIP: ""
20+
21+
# Optional override for the link Layer2VIPConfig is pinned to. When
22+
# left empty the chart picks the default-gateway-bearing link the
23+
# node already has (the VLAN sub-interface if one carries the
24+
# default route, otherwise the physical NIC). Set this when the
25+
# target link does not yet exist on the live system at first apply
26+
# — typically a VLAN sub-interface that the same template is about
27+
# to bring up. Without an override the chart would derive the link
28+
# from discovery on the bare-metal NIC, pin the VIP there, and the
29+
# VIP would land on the wrong link once the VLAN comes up.
30+
# When set, Layer2VIPConfig is emitted unconditionally, even on a
31+
# totally fresh node where discovery has not yet resolved a default-
32+
# gateway link. The chart does NOT auto-emit a LinkConfig/VLANConfig
33+
# for the override link; the operator is responsible for ensuring
34+
# the link comes up — typically by adding a LinkConfig or VLANConfig
35+
# document for that link to the per-node body overlay. If no such
36+
# document brings vipLink up, Layer2VIPConfig will dangle on a
37+
# non-existent link and the cluster endpoint will be unreachable.
38+
# Example: vipLink: eth0.4000
39+
vipLink: ""
40+
1141
podSubnets:
1242
- 10.244.0.0/16
1343
serviceSubnets:

0 commit comments

Comments
 (0)