mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
Merge pull request #21373 from enoodle/read_cadvisor_cloudinfo_in_kubelet
kubelet: reading cloudinfo from cadvisor
This commit is contained in:
commit
91f8c784a0
@ -1071,6 +1071,11 @@ func (kl *Kubelet) initialNodeStatus() (*api.Node, error) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
node.Spec.ExternalID = kl.hostname
|
node.Spec.ExternalID = kl.hostname
|
||||||
|
// If no cloud provider is defined - use the one detected by cadvisor
|
||||||
|
info, err := kl.GetCachedMachineInfo()
|
||||||
|
if err == nil {
|
||||||
|
kl.updateCloudProviderFromMachineInfo(node, info)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err := kl.setNodeStatus(node); err != nil {
|
if err := kl.setNodeStatus(node); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -3030,6 +3035,18 @@ func (kl *Kubelet) setNodeAddress(node *api.Node) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (kl *Kubelet) updateCloudProviderFromMachineInfo(node *api.Node, info *cadvisorapi.MachineInfo) {
|
||||||
|
if info.CloudProvider != cadvisorapi.UnknownProvider &&
|
||||||
|
info.CloudProvider != cadvisorapi.Baremetal {
|
||||||
|
// The cloud providers from pkg/cloudprovider/providers/* that update ProviderID
|
||||||
|
// will use the format of cloudprovider://project/availability_zone/instance_name
|
||||||
|
// here we only have the cloudprovider and the instance name so we leave project
|
||||||
|
// and availability zone empty for compatibility.
|
||||||
|
node.Spec.ProviderID = strings.ToLower(string(info.CloudProvider)) +
|
||||||
|
":////" + string(info.InstanceID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (kl *Kubelet) setNodeStatusMachineInfo(node *api.Node) {
|
func (kl *Kubelet) setNodeStatusMachineInfo(node *api.Node) {
|
||||||
// TODO: Post NotReady if we cannot get MachineInfo from cAdvisor. This needs to start
|
// TODO: Post NotReady if we cannot get MachineInfo from cAdvisor. This needs to start
|
||||||
// cAdvisor locally, e.g. for test-cmd.sh, and in integration test.
|
// cAdvisor locally, e.g. for test-cmd.sh, and in integration test.
|
||||||
|
Loading…
Reference in New Issue
Block a user