mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Merge pull request #28258 from vishh/28231
Automatic merge from submit-queue [kubelet] Allow opting out of automatic cloud provider detection in kubelet. By default kubelet will auto-detect cloud providers fixes #28231
This commit is contained in:
commit
ab37fbf4c2
@ -43,6 +43,8 @@ const (
|
|||||||
// When these values are updated, also update test/e2e/framework/util.go
|
// When these values are updated, also update test/e2e/framework/util.go
|
||||||
defaultPodInfraContainerImageName = "gcr.io/google_containers/pause"
|
defaultPodInfraContainerImageName = "gcr.io/google_containers/pause"
|
||||||
defaultPodInfraContainerImageVersion = "3.0"
|
defaultPodInfraContainerImageVersion = "3.0"
|
||||||
|
// Auto detect cloud provider.
|
||||||
|
AutoDetectCloudProvider = "auto-detect"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Returns the arch-specific pause image that kubelet should use as the default
|
// Returns the arch-specific pause image that kubelet should use as the default
|
||||||
@ -83,6 +85,7 @@ func NewKubeletServer() *KubeletServer {
|
|||||||
VolumeStatsAggPeriod: unversioned.Duration{Duration: time.Minute},
|
VolumeStatsAggPeriod: unversioned.Duration{Duration: time.Minute},
|
||||||
CertDirectory: "/var/run/kubernetes",
|
CertDirectory: "/var/run/kubernetes",
|
||||||
CgroupRoot: "",
|
CgroupRoot: "",
|
||||||
|
CloudProvider: AutoDetectCloudProvider,
|
||||||
ConfigureCBR0: false,
|
ConfigureCBR0: false,
|
||||||
ContainerRuntime: "docker",
|
ContainerRuntime: "docker",
|
||||||
RuntimeRequestTimeout: unversioned.Duration{Duration: 2 * time.Minute},
|
RuntimeRequestTimeout: unversioned.Duration{Duration: 2 * time.Minute},
|
||||||
@ -218,7 +221,7 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
|
|||||||
fs.StringVar(&s.NetworkPluginName, "network-plugin", s.NetworkPluginName, "<Warning: Alpha feature> The name of the network plugin to be invoked for various events in kubelet/pod lifecycle")
|
fs.StringVar(&s.NetworkPluginName, "network-plugin", s.NetworkPluginName, "<Warning: Alpha feature> The name of the network plugin to be invoked for various events in kubelet/pod lifecycle")
|
||||||
fs.StringVar(&s.NetworkPluginDir, "network-plugin-dir", s.NetworkPluginDir, "<Warning: Alpha feature> The full path of the directory in which to search for network plugins")
|
fs.StringVar(&s.NetworkPluginDir, "network-plugin-dir", s.NetworkPluginDir, "<Warning: Alpha feature> The full path of the directory in which to search for network plugins")
|
||||||
fs.StringVar(&s.VolumePluginDir, "volume-plugin-dir", s.VolumePluginDir, "<Warning: Alpha feature> The full path of the directory in which to search for additional third party volume plugins")
|
fs.StringVar(&s.VolumePluginDir, "volume-plugin-dir", s.VolumePluginDir, "<Warning: Alpha feature> The full path of the directory in which to search for additional third party volume plugins")
|
||||||
fs.StringVar(&s.CloudProvider, "cloud-provider", s.CloudProvider, "The provider for cloud services. Empty string for no provider.")
|
fs.StringVar(&s.CloudProvider, "cloud-provider", s.CloudProvider, "The provider for cloud services. By default, kubelet will attempt to auto-detect the cloud provider. Specify empty string for running with no cloud provider. [default=auto-detect]")
|
||||||
fs.StringVar(&s.CloudConfigFile, "cloud-config", s.CloudConfigFile, "The path to the cloud provider configuration file. Empty string for no configuration file.")
|
fs.StringVar(&s.CloudConfigFile, "cloud-config", s.CloudConfigFile, "The path to the cloud provider configuration file. Empty string for no configuration file.")
|
||||||
|
|
||||||
fs.StringVar(&s.KubeletCgroups, "resource-container", s.KubeletCgroups, "Optional absolute name of the resource-only container to create and run the Kubelet in.")
|
fs.StringVar(&s.KubeletCgroups, "resource-container", s.KubeletCgroups, "Optional absolute name of the resource-only container to create and run the Kubelet in.")
|
||||||
|
@ -339,12 +339,16 @@ func run(s *options.KubeletServer, kcfg *KubeletConfig) (err error) {
|
|||||||
glog.Warningf("No API client: %v", err)
|
glog.Warningf("No API client: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cloud, err := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
|
if s.CloudProvider == options.AutoDetectCloudProvider {
|
||||||
if err != nil {
|
kcfg.AutoDetectCloudProvider = true
|
||||||
return err
|
} else {
|
||||||
|
cloud, err := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
glog.V(2).Infof("Successfully initialized cloud provider: %q from the config file: %q\n", s.CloudProvider, s.CloudConfigFile)
|
||||||
|
kcfg.Cloud = cloud
|
||||||
}
|
}
|
||||||
glog.V(2).Infof("Successfully initialized cloud provider: %q from the config file: %q\n", s.CloudProvider, s.CloudConfigFile)
|
|
||||||
kcfg.Cloud = cloud
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if kcfg.CAdvisorInterface == nil {
|
if kcfg.CAdvisorInterface == nil {
|
||||||
@ -773,6 +777,7 @@ type KubeletConfig struct {
|
|||||||
Address net.IP
|
Address net.IP
|
||||||
AllowPrivileged bool
|
AllowPrivileged bool
|
||||||
Auth server.AuthInterface
|
Auth server.AuthInterface
|
||||||
|
AutoDetectCloudProvider bool
|
||||||
Builder KubeletBuilder
|
Builder KubeletBuilder
|
||||||
CAdvisorInterface cadvisor.Interface
|
CAdvisorInterface cadvisor.Interface
|
||||||
VolumeStatsAggPeriod time.Duration
|
VolumeStatsAggPeriod time.Duration
|
||||||
@ -920,6 +925,7 @@ func CreateAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod
|
|||||||
kc.ImageGCPolicy,
|
kc.ImageGCPolicy,
|
||||||
kc.DiskSpacePolicy,
|
kc.DiskSpacePolicy,
|
||||||
kc.Cloud,
|
kc.Cloud,
|
||||||
|
kc.AutoDetectCloudProvider,
|
||||||
kc.NodeLabels,
|
kc.NodeLabels,
|
||||||
kc.NodeStatusUpdateFrequency,
|
kc.NodeStatusUpdateFrequency,
|
||||||
kc.OSInterface,
|
kc.OSInterface,
|
||||||
|
@ -201,6 +201,7 @@ func NewMainKubelet(
|
|||||||
imageGCPolicy ImageGCPolicy,
|
imageGCPolicy ImageGCPolicy,
|
||||||
diskSpacePolicy DiskSpacePolicy,
|
diskSpacePolicy DiskSpacePolicy,
|
||||||
cloud cloudprovider.Interface,
|
cloud cloudprovider.Interface,
|
||||||
|
autoDetectCloudProvider bool,
|
||||||
nodeLabels map[string]string,
|
nodeLabels map[string]string,
|
||||||
nodeStatusUpdateFrequency time.Duration,
|
nodeStatusUpdateFrequency time.Duration,
|
||||||
osInterface kubecontainer.OSInterface,
|
osInterface kubecontainer.OSInterface,
|
||||||
@ -331,9 +332,10 @@ func NewMainKubelet(
|
|||||||
cadvisor: cadvisorInterface,
|
cadvisor: cadvisorInterface,
|
||||||
diskSpaceManager: diskSpaceManager,
|
diskSpaceManager: diskSpaceManager,
|
||||||
cloud: cloud,
|
cloud: cloud,
|
||||||
nodeRef: nodeRef,
|
autoDetectCloudProvider: autoDetectCloudProvider,
|
||||||
nodeLabels: nodeLabels,
|
nodeRef: nodeRef,
|
||||||
nodeStatusUpdateFrequency: nodeStatusUpdateFrequency,
|
nodeLabels: nodeLabels,
|
||||||
|
nodeStatusUpdateFrequency: nodeStatusUpdateFrequency,
|
||||||
os: osInterface,
|
os: osInterface,
|
||||||
oomWatcher: oomWatcher,
|
oomWatcher: oomWatcher,
|
||||||
cgroupRoot: cgroupRoot,
|
cgroupRoot: cgroupRoot,
|
||||||
@ -688,7 +690,8 @@ type Kubelet struct {
|
|||||||
volumeManager kubeletvolume.VolumeManager
|
volumeManager kubeletvolume.VolumeManager
|
||||||
|
|
||||||
// Cloud provider interface.
|
// Cloud provider interface.
|
||||||
cloud cloudprovider.Interface
|
cloud cloudprovider.Interface
|
||||||
|
autoDetectCloudProvider bool
|
||||||
|
|
||||||
// Reference to this node.
|
// Reference to this node.
|
||||||
nodeRef *api.ObjectReference
|
nodeRef *api.ObjectReference
|
||||||
@ -1115,10 +1118,12 @@ 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
|
if kl.autoDetectCloudProvider {
|
||||||
info, err := kl.GetCachedMachineInfo()
|
// If no cloud provider is defined - use the one detected by cadvisor
|
||||||
if err == nil {
|
info, err := kl.GetCachedMachineInfo()
|
||||||
kl.updateCloudProviderFromMachineInfo(node, info)
|
if err == nil {
|
||||||
|
kl.updateCloudProviderFromMachineInfo(node, info)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := kl.setNodeStatus(node); err != nil {
|
if err := kl.setNodeStatus(node); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user