mirror of
https://github.com/siderolabs/talos.git
synced 2026-05-05 12:26:21 +02:00
fix: upgrade-k8s use internal IP first, external IP fallback
Currently, upgrade-k8s adds both node internal and external IPs. This commit uses the internal IP if available; external IP is only used as a fallback. Signed-off-by: Alex Lubbock <code@alexlubbock.com> Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
This commit is contained in:
parent
3c64a5ffba
commit
ecce29dee9
@ -154,7 +154,7 @@ func (h *Client) NodeIPs(ctx context.Context, machineType machine.Type) (addrs [
|
||||
for _, node := range resp.Items {
|
||||
_, labelControlPlane := node.Labels[constants.LabelNodeRoleControlPlane]
|
||||
|
||||
var skip bool
|
||||
var skip, foundInternalIP bool
|
||||
|
||||
switch machineType {
|
||||
case machine.TypeInit, machine.TypeControlPlane:
|
||||
@ -175,17 +175,20 @@ func (h *Client) NodeIPs(ctx context.Context, machineType machine.Type) (addrs [
|
||||
for _, nodeAddress := range node.Status.Addresses {
|
||||
if nodeAddress.Type == corev1.NodeInternalIP {
|
||||
addrs = append(addrs, nodeAddress.Address)
|
||||
foundInternalIP = true
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// no internal IP, fallback to external IP
|
||||
for _, nodeAddress := range node.Status.Addresses {
|
||||
if nodeAddress.Type == corev1.NodeExternalIP {
|
||||
addrs = append(addrs, nodeAddress.Address)
|
||||
if !foundInternalIP {
|
||||
// no internal IP, fallback to external IP
|
||||
for _, nodeAddress := range node.Status.Addresses {
|
||||
if nodeAddress.Type == corev1.NodeExternalIP {
|
||||
addrs = append(addrs, nodeAddress.Address)
|
||||
|
||||
break
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user