mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Merge pull request #50422 from karataliu/apid
Automatic merge from submit-queue (batch tested with PRs 50294, 50422, 51757, 52379, 52014). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.. Fix AnnotationProvidedIPAddr annotation for externalCloudProvider **What this PR does / why we need it**: In #44258, it introduced `AnnotationProvidedIPAddr`. When kubelet has 'node-ip' parameter set, and cloud provider not set, this annotation would be populated, and then will be validated by cloud-controller-manager: https://github.com/kubernetes/kubernetes/pull/44258/files#diff-6b0808bd1afb15f9f77986f4459601c2R465 Later with #47152, externalCloudProvider is checked and func returns before that annotation got set. In this case, that annotation will not get populated. This fix is to bring that annotation assignment to a proper location. Please correct me if I have any misunderstanding. @wlan0 @ublubu **Which issue this PR fixes** **Special notes for your reviewer**: **Release note**:
This commit is contained in:
commit
2c5413b379
@ -452,6 +452,9 @@ func (kl *Kubelet) setNodeAddress(node *v1.Node) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if kl.externalCloudProvider {
|
if kl.externalCloudProvider {
|
||||||
|
if kl.nodeIP != nil {
|
||||||
|
node.ObjectMeta.Annotations[kubeletapis.AnnotationProvidedIPAddr] = kl.nodeIP.String()
|
||||||
|
}
|
||||||
// We rely on the external cloud provider to supply the addresses.
|
// We rely on the external cloud provider to supply the addresses.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -509,7 +512,6 @@ func (kl *Kubelet) setNodeAddress(node *v1.Node) error {
|
|||||||
// 4) Try to get the IP from the network interface used as default gateway
|
// 4) Try to get the IP from the network interface used as default gateway
|
||||||
if kl.nodeIP != nil {
|
if kl.nodeIP != nil {
|
||||||
ipAddr = kl.nodeIP
|
ipAddr = kl.nodeIP
|
||||||
node.ObjectMeta.Annotations[kubeletapis.AnnotationProvidedIPAddr] = kl.nodeIP.String()
|
|
||||||
} else if addr := net.ParseIP(kl.hostname); addr != nil {
|
} else if addr := net.ParseIP(kl.hostname); addr != nil {
|
||||||
ipAddr = addr
|
ipAddr = addr
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user