mirror of
https://github.com/siderolabs/talos.git
synced 2026-05-05 12:26:21 +02:00
fix: fall back to external IP when discovering nodes in upgrade-k8s
Fixes #7253 Also fix the case that `kube-proxy` version was updated in the machine config in `--dry-run` mode. Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
This commit is contained in:
parent
0bb7e8a5cf
commit
ea9a97dba3
@ -126,6 +126,8 @@ func upgradeKubeProxy(ctx context.Context, cluster UpgradeProvider, options Upgr
|
||||
options.Log("updating kube-proxy to version %q", options.Path.ToVersion())
|
||||
|
||||
for _, node := range options.controlPlaneNodes {
|
||||
options.Log(" > %q: starting update", node)
|
||||
|
||||
if err := patchNodeConfig(ctx, cluster, node, patchKubeProxy(options)); err != nil {
|
||||
return fmt.Errorf("error updating node %q: %w", node, err)
|
||||
}
|
||||
@ -136,6 +138,12 @@ func upgradeKubeProxy(ctx context.Context, cluster UpgradeProvider, options Upgr
|
||||
|
||||
func patchKubeProxy(options UpgradeOptions) func(config *v1alpha1config.Config) error {
|
||||
return func(config *v1alpha1config.Config) error {
|
||||
if options.DryRun {
|
||||
options.Log(" > skipped in dry-run")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
if config.ClusterConfig == nil {
|
||||
config.ClusterConfig = &v1alpha1config.ClusterConfig{}
|
||||
}
|
||||
|
||||
@ -171,6 +171,7 @@ func (h *Client) NodeIPs(ctx context.Context, machineType machine.Type) (addrs [
|
||||
continue
|
||||
}
|
||||
|
||||
// try to get the internal IP address
|
||||
for _, nodeAddress := range node.Status.Addresses {
|
||||
if nodeAddress.Type == corev1.NodeInternalIP {
|
||||
addrs = append(addrs, nodeAddress.Address)
|
||||
@ -178,6 +179,15 @@ func (h *Client) NodeIPs(ctx context.Context, machineType machine.Type) (addrs [
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// no internal IP, fallback to external IP
|
||||
for _, nodeAddress := range node.Status.Addresses {
|
||||
if nodeAddress.Type == corev1.NodeExternalIP {
|
||||
addrs = append(addrs, nodeAddress.Address)
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return addrs, nil
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user