mirror of
				https://github.com/siderolabs/talos.git
				synced 2025-10-31 08:21:25 +01: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()) | 	options.Log("updating kube-proxy to version %q", options.Path.ToVersion()) | ||||||
| 
 | 
 | ||||||
| 	for _, node := range options.controlPlaneNodes { | 	for _, node := range options.controlPlaneNodes { | ||||||
|  | 		options.Log(" > %q: starting update", node) | ||||||
|  | 
 | ||||||
| 		if err := patchNodeConfig(ctx, cluster, node, patchKubeProxy(options)); err != nil { | 		if err := patchNodeConfig(ctx, cluster, node, patchKubeProxy(options)); err != nil { | ||||||
| 			return fmt.Errorf("error updating node %q: %w", node, err) | 			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 { | func patchKubeProxy(options UpgradeOptions) func(config *v1alpha1config.Config) error { | ||||||
| 	return 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 { | 		if config.ClusterConfig == nil { | ||||||
| 			config.ClusterConfig = &v1alpha1config.ClusterConfig{} | 			config.ClusterConfig = &v1alpha1config.ClusterConfig{} | ||||||
| 		} | 		} | ||||||
|  | |||||||
| @ -171,6 +171,7 @@ func (h *Client) NodeIPs(ctx context.Context, machineType machine.Type) (addrs [ | |||||||
| 			continue | 			continue | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | 		// try to get the internal IP address | ||||||
| 		for _, nodeAddress := range node.Status.Addresses { | 		for _, nodeAddress := range node.Status.Addresses { | ||||||
| 			if nodeAddress.Type == corev1.NodeInternalIP { | 			if nodeAddress.Type == corev1.NodeInternalIP { | ||||||
| 				addrs = append(addrs, nodeAddress.Address) | 				addrs = append(addrs, nodeAddress.Address) | ||||||
| @ -178,6 +179,15 @@ func (h *Client) NodeIPs(ctx context.Context, machineType machine.Type) (addrs [ | |||||||
| 				break | 				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 | 	return addrs, nil | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user