Merge pull request #121028 from aojea/external_node

kubelet: cloud-provider external addresses
This commit is contained in:
Kubernetes Prow Robot 2023-10-07 03:03:01 +02:00 committed by GitHub
commit fc479f41b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 2 deletions

View File

@ -123,11 +123,19 @@ func NodeAddress(nodeIPs []net.IP, // typically Kubelet.nodeIPs
if externalCloudProvider {
// If --cloud-provider=external and node address is already set,
// then we return early because provider set addresses should take precedence.
// Otherwise, we try to look up the node IP and let the cloud provider override it later
// Otherwise, we try to use the node IP defined via flags and let the cloud provider override it later
// This should alleviate a lot of the bootstrapping issues with out-of-tree providers
if len(node.Status.Addresses) > 0 {
return nil
}
// If nodeIPs are not specified wait for the external cloud-provider to set the node addresses.
// Otherwise uses them on the assumption that the installer/administrator has the previous knowledge
// required to ensure the external cloud provider will use the same addresses to avoid the issues explained
// in https://github.com/kubernetes/kubernetes/issues/120720.
// We are already hinting the external cloud provider via the annotation AnnotationAlphaProvidedIPAddr.
if !nodeIPSpecified {
return nil
}
}
if cloud != nil {
cloudNodeAddresses, err := nodeAddressesFunc()

View File

@ -223,7 +223,7 @@ func TestNodeAddress(t *testing.T) {
shouldError: false,
},
{
name: "cloud provider is external",
name: "cloud provider is external and nodeIP specified",
nodeIP: netutils.ParseIPSloppy("10.0.0.1"),
nodeAddresses: []v1.NodeAddress{},
cloudProviderType: cloudProviderExternal,
@ -233,6 +233,21 @@ func TestNodeAddress(t *testing.T) {
},
shouldError: false,
},
{
name: "cloud provider is external and nodeIP unspecified",
nodeIP: netutils.ParseIPSloppy("::"),
nodeAddresses: []v1.NodeAddress{},
cloudProviderType: cloudProviderExternal,
expectedAddresses: []v1.NodeAddress{},
shouldError: false,
},
{
name: "cloud provider is external and no nodeIP",
nodeAddresses: []v1.NodeAddress{},
cloudProviderType: cloudProviderExternal,
expectedAddresses: []v1.NodeAddress{},
shouldError: false,
},
{
name: "cloud doesn't report hostname, no override, detected hostname mismatch",
nodeAddresses: []v1.NodeAddress{