mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Merge pull request #121028 from aojea/external_node
kubelet: cloud-provider external addresses
This commit is contained in:
commit
fc479f41b3
@ -123,11 +123,19 @@ func NodeAddress(nodeIPs []net.IP, // typically Kubelet.nodeIPs
|
|||||||
if externalCloudProvider {
|
if externalCloudProvider {
|
||||||
// If --cloud-provider=external and node address is already set,
|
// If --cloud-provider=external and node address is already set,
|
||||||
// then we return early because provider set addresses should take precedence.
|
// 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
|
// This should alleviate a lot of the bootstrapping issues with out-of-tree providers
|
||||||
if len(node.Status.Addresses) > 0 {
|
if len(node.Status.Addresses) > 0 {
|
||||||
return nil
|
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 {
|
if cloud != nil {
|
||||||
cloudNodeAddresses, err := nodeAddressesFunc()
|
cloudNodeAddresses, err := nodeAddressesFunc()
|
||||||
|
@ -223,7 +223,7 @@ func TestNodeAddress(t *testing.T) {
|
|||||||
shouldError: false,
|
shouldError: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "cloud provider is external",
|
name: "cloud provider is external and nodeIP specified",
|
||||||
nodeIP: netutils.ParseIPSloppy("10.0.0.1"),
|
nodeIP: netutils.ParseIPSloppy("10.0.0.1"),
|
||||||
nodeAddresses: []v1.NodeAddress{},
|
nodeAddresses: []v1.NodeAddress{},
|
||||||
cloudProviderType: cloudProviderExternal,
|
cloudProviderType: cloudProviderExternal,
|
||||||
@ -233,6 +233,21 @@ func TestNodeAddress(t *testing.T) {
|
|||||||
},
|
},
|
||||||
shouldError: false,
|
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",
|
name: "cloud doesn't report hostname, no override, detected hostname mismatch",
|
||||||
nodeAddresses: []v1.NodeAddress{
|
nodeAddresses: []v1.NodeAddress{
|
||||||
|
Loading…
Reference in New Issue
Block a user