mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 05:21:58 +00:00
node-ip unspecified addresses initialize Node with cloud provider external
The node.status.addresses logic grew organically and with weird semantics, this commit try to document existing semantics when the kubelet uses an external cloud provider and recover the same behavior existing pre-1.29. The node.status.addresses can be populated by the kubelet at startup or delegated to the external cloud provider. If the --node-ip flag is set to an IP in the node, the kubelet will add an annotation to the Node object that will be respected by the external cloud providers, no new IP addresses will be added for the same address type. If the IP set in the --node-ip flag is `0.0.0.0` or `::`, the kubelet will initialize the node with the default address of the corresponding IP family of the unspecified address, and the cloud-provider will override it later.
This commit is contained in:
parent
d1d9b3661d
commit
22fba6591d
@ -292,7 +292,7 @@ func (f *KubeletFlags) AddFlags(mainfs *pflag.FlagSet) {
|
||||
|
||||
fs.StringVar(&f.HostnameOverride, "hostname-override", f.HostnameOverride, "If non-empty, will use this string as identification instead of the actual hostname. If --cloud-provider is set, the cloud provider determines the name of the node (consult cloud provider documentation to determine if and how the hostname is used).")
|
||||
|
||||
fs.StringVar(&f.NodeIP, "node-ip", f.NodeIP, "IP address (or comma-separated dual-stack IP addresses) of the node. If unset, kubelet will use the node's default IPv4 address, if any, or its default IPv6 address if it has no IPv4 addresses. You can pass '::' to make it prefer the default IPv6 address rather than the default IPv4 address.")
|
||||
fs.StringVar(&f.NodeIP, "node-ip", f.NodeIP, "IP address (or comma-separated dual-stack IP addresses) of the node. If unset, kubelet will use the node's default IPv4 address, if any, or its default IPv6 address if it has no IPv4 addresses. You can pass '::' to make it prefer the default IPv6 address rather than the default IPv4 address. If cloud-provider is set to external, this flag will help to bootstrap the node with the corresponding IP.")
|
||||
|
||||
fs.StringVar(&f.CertDirectory, "cert-dir", f.CertDirectory, "The directory where the TLS certs are located. "+
|
||||
"If --tls-cert-file and --tls-private-key-file are provided, this flag will be ignored.")
|
||||
|
@ -129,12 +129,15 @@ func NodeAddress(nodeIPs []net.IP, // typically Kubelet.nodeIPs
|
||||
if len(node.Status.Addresses) > 0 {
|
||||
return nil
|
||||
}
|
||||
// If nodeIPs are not specified wait for the external cloud-provider to set the node addresses.
|
||||
// If nodeIPs are not set wait for the external cloud-provider to set the node addresses.
|
||||
// If the nodeIP is the unspecified address 0.0.0.0 or ::, then use the IP of the default gateway of
|
||||
// the corresponding IP family to bootstrap the node until the out-of-tree provider overrides it later.
|
||||
// xref: https://github.com/kubernetes/kubernetes/issues/125348
|
||||
// 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 {
|
||||
if nodeIP == nil {
|
||||
node.Status.Addresses = []v1.NodeAddress{
|
||||
{Type: v1.NodeHostName, Address: hostname},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user