Merge pull request #5827 from spothanis/master

added cloud provider flag to kubelet
This commit is contained in:
Victor Marmol 2015-03-25 10:50:18 -07:00
commit f7135b3dd4
5 changed files with 34 additions and 6 deletions

View File

@ -226,14 +226,14 @@ func startComponents(firstManifestURL, secondManifestURL, apiVersion string) (st
testRootDir := makeTempDirOrDie("kubelet_integ_1.", "") testRootDir := makeTempDirOrDie("kubelet_integ_1.", "")
configFilePath := makeTempDirOrDie("config", testRootDir) configFilePath := makeTempDirOrDie("config", testRootDir)
glog.Infof("Using %s as root dir for kubelet #1", testRootDir) glog.Infof("Using %s as root dir for kubelet #1", testRootDir)
kcfg := kubeletapp.SimpleKubelet(cl, &fakeDocker1, machineList[0], testRootDir, firstManifestURL, "127.0.0.1", 10250, api.NamespaceDefault, empty_dir.ProbeVolumePlugins(), nil, cadvisorInterface, configFilePath) kcfg := kubeletapp.SimpleKubelet(cl, &fakeDocker1, machineList[0], testRootDir, firstManifestURL, "127.0.0.1", 10250, api.NamespaceDefault, empty_dir.ProbeVolumePlugins(), nil, cadvisorInterface, configFilePath, nil)
kubeletapp.RunKubelet(kcfg) kubeletapp.RunKubelet(kcfg)
// Kubelet (machine) // Kubelet (machine)
// Create a second kubelet so that the guestbook example's two redis slaves both // Create a second kubelet so that the guestbook example's two redis slaves both
// have a place they can schedule. // have a place they can schedule.
testRootDir = makeTempDirOrDie("kubelet_integ_2.", "") testRootDir = makeTempDirOrDie("kubelet_integ_2.", "")
glog.Infof("Using %s as root dir for kubelet #2", testRootDir) glog.Infof("Using %s as root dir for kubelet #2", testRootDir)
kcfg = kubeletapp.SimpleKubelet(cl, &fakeDocker2, machineList[1], testRootDir, secondManifestURL, "127.0.0.1", 10251, api.NamespaceDefault, empty_dir.ProbeVolumePlugins(), nil, cadvisorInterface, "") kcfg = kubeletapp.SimpleKubelet(cl, &fakeDocker2, machineList[1], testRootDir, secondManifestURL, "127.0.0.1", 10251, api.NamespaceDefault, empty_dir.ProbeVolumePlugins(), nil, cadvisorInterface, "", nil)
kubeletapp.RunKubelet(kcfg) kubeletapp.RunKubelet(kcfg)
return apiServer.URL, configFilePath return apiServer.URL, configFilePath
} }

View File

@ -31,6 +31,13 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume/host_path" "github.com/GoogleCloudPlatform/kubernetes/pkg/volume/host_path"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume/nfs" "github.com/GoogleCloudPlatform/kubernetes/pkg/volume/nfs"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume/secret" "github.com/GoogleCloudPlatform/kubernetes/pkg/volume/secret"
//Cloud providers
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/aws"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/gce"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/openstack"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/ovirt"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/rackspace"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/vagrant"
) )
// ProbeVolumePlugins collects all volume plugins into an easy to use list. // ProbeVolumePlugins collects all volume plugins into an easy to use list.

View File

@ -38,6 +38,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume" "github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
"github.com/golang/glog" "github.com/golang/glog"
"github.com/spf13/pflag" "github.com/spf13/pflag"
) )
@ -79,6 +80,8 @@ type KubeletServer struct {
ImageGCHighThresholdPercent int ImageGCHighThresholdPercent int
ImageGCLowThresholdPercent int ImageGCLowThresholdPercent int
NetworkPluginName string NetworkPluginName string
CloudProvider string
CloudConfigFile string
} }
// NewKubeletServer will create a new KubeletServer with default values. // NewKubeletServer will create a new KubeletServer with default values.
@ -140,6 +143,8 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
fs.IntVar(&s.ImageGCHighThresholdPercent, "image_gc_high_threshold", s.ImageGCHighThresholdPercent, "The percent of disk usage after which image garbage collection is always run. Default: 90%%") fs.IntVar(&s.ImageGCHighThresholdPercent, "image_gc_high_threshold", s.ImageGCHighThresholdPercent, "The percent of disk usage after which image garbage collection is always run. Default: 90%%")
fs.IntVar(&s.ImageGCLowThresholdPercent, "image_gc_low_threshold", s.ImageGCLowThresholdPercent, "The percent of disk usage before which image garbage collection is never run. Lowest disk usage to garbage collect to. Default: 80%%") fs.IntVar(&s.ImageGCLowThresholdPercent, "image_gc_low_threshold", s.ImageGCLowThresholdPercent, "The percent of disk usage before which image garbage collection is never run. Lowest disk usage to garbage collect to. Default: 80%%")
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.CloudProvider, "cloud_provider", s.CloudProvider, "The provider for cloud services. Empty string for no provider.")
fs.StringVar(&s.CloudConfigFile, "cloud_config", s.CloudConfigFile, "The path to the cloud provider configuration file. Empty string for no configuration file.")
} }
// Run runs the specified KubeletServer. This should never exit. // Run runs the specified KubeletServer. This should never exit.
@ -169,6 +174,10 @@ func (s *KubeletServer) Run(_ []string) error {
HighThresholdPercent: s.ImageGCHighThresholdPercent, HighThresholdPercent: s.ImageGCHighThresholdPercent,
LowThresholdPercent: s.ImageGCLowThresholdPercent, LowThresholdPercent: s.ImageGCLowThresholdPercent,
} }
cloud := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
glog.Infof("Successfully initialized cloud provider: %q from the config file: %q\n", s.CloudProvider, s.CloudConfigFile)
kcfg := KubeletConfig{ kcfg := KubeletConfig{
Address: s.Address, Address: s.Address,
AllowPrivileged: s.AllowPrivileged, AllowPrivileged: s.AllowPrivileged,
@ -200,6 +209,7 @@ func (s *KubeletServer) Run(_ []string) error {
NetworkPluginName: s.NetworkPluginName, NetworkPluginName: s.NetworkPluginName,
StreamingConnectionIdleTimeout: s.StreamingConnectionIdleTimeout, StreamingConnectionIdleTimeout: s.StreamingConnectionIdleTimeout,
ImageGCPolicy: imageGCPolicy, ImageGCPolicy: imageGCPolicy,
Cloud: cloud,
} }
RunKubelet(&kcfg) RunKubelet(&kcfg)
@ -262,7 +272,8 @@ func SimpleKubelet(client *client.Client,
volumePlugins []volume.VolumePlugin, volumePlugins []volume.VolumePlugin,
tlsOptions *kubelet.TLSOptions, tlsOptions *kubelet.TLSOptions,
cadvisorInterface cadvisor.Interface, cadvisorInterface cadvisor.Interface,
configFilePath string) *KubeletConfig { configFilePath string,
cloud cloudprovider.Interface) *KubeletConfig {
imageGCPolicy := kubelet.ImageGCPolicy{ imageGCPolicy := kubelet.ImageGCPolicy{
HighThresholdPercent: 90, HighThresholdPercent: 90,
@ -291,6 +302,7 @@ func SimpleKubelet(client *client.Client,
CadvisorInterface: cadvisorInterface, CadvisorInterface: cadvisorInterface,
ConfigFile: configFilePath, ConfigFile: configFilePath,
ImageGCPolicy: imageGCPolicy, ImageGCPolicy: imageGCPolicy,
Cloud: cloud,
} }
return &kcfg return &kcfg
} }
@ -399,6 +411,7 @@ type KubeletConfig struct {
Recorder record.EventRecorder Recorder record.EventRecorder
TLSOptions *kubelet.TLSOptions TLSOptions *kubelet.TLSOptions
ImageGCPolicy kubelet.ImageGCPolicy ImageGCPolicy kubelet.ImageGCPolicy
Cloud cloudprovider.Interface
} }
func createAndInitKubelet(kc *KubeletConfig, pc *config.PodConfig) (*kubelet.Kubelet, error) { func createAndInitKubelet(kc *KubeletConfig, pc *config.PodConfig) (*kubelet.Kubelet, error) {
@ -440,7 +453,8 @@ func createAndInitKubelet(kc *KubeletConfig, pc *config.PodConfig) (*kubelet.Kub
kc.StreamingConnectionIdleTimeout, kc.StreamingConnectionIdleTimeout,
kc.Recorder, kc.Recorder,
kc.CadvisorInterface, kc.CadvisorInterface,
kc.ImageGCPolicy) kc.ImageGCPolicy,
kc.Cloud)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -150,8 +150,9 @@ func startComponents(etcdClient tools.EtcdClient, cl *client.Client, addr net.IP
if err != nil { if err != nil {
glog.Fatalf("Failed to create cAdvisor: %v", err) glog.Fatalf("Failed to create cAdvisor: %v", err)
} }
kcfg := kubeletapp.SimpleKubelet(cl, dockerClient, machineList[0], "/tmp/kubernetes", "", "127.0.0.1", 10250, *masterServiceNamespace, kubeletapp.ProbeVolumePlugins(), nil, cadvisorInterface, "") kcfg := kubeletapp.SimpleKubelet(cl, dockerClient, machineList[0], "/tmp/kubernetes", "", "127.0.0.1", 10250, *masterServiceNamespace, kubeletapp.ProbeVolumePlugins(), nil, cadvisorInterface, "", nil)
kubeletapp.RunKubelet(kcfg) kubeletapp.RunKubelet(kcfg)
} }
func newApiClient(addr net.IP, port int) *client.Client { func newApiClient(addr net.IP, port int) *client.Client {

View File

@ -37,6 +37,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record" "github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields" "github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/cadvisor" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/cadvisor"
kubecontainer "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container" kubecontainer "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
@ -137,7 +138,8 @@ func NewMainKubelet(
streamingConnectionIdleTimeout time.Duration, streamingConnectionIdleTimeout time.Duration,
recorder record.EventRecorder, recorder record.EventRecorder,
cadvisorInterface cadvisor.Interface, cadvisorInterface cadvisor.Interface,
imageGCPolicy ImageGCPolicy) (*Kubelet, error) { imageGCPolicy ImageGCPolicy,
cloud cloudprovider.Interface) (*Kubelet, error) {
if rootDirectory == "" { if rootDirectory == "" {
return nil, fmt.Errorf("invalid root directory %q", rootDirectory) return nil, fmt.Errorf("invalid root directory %q", rootDirectory)
} }
@ -235,6 +237,7 @@ func NewMainKubelet(
containerGC: containerGC, containerGC: containerGC,
imageManager: imageManager, imageManager: imageManager,
statusManager: statusManager, statusManager: statusManager,
cloud: cloud,
} }
klet.podManager = newBasicPodManager(klet.kubeClient) klet.podManager = newBasicPodManager(klet.kubeClient)
@ -351,6 +354,9 @@ type Kubelet struct {
// Syncs pods statuses with apiserver; also used as a cache of statuses. // Syncs pods statuses with apiserver; also used as a cache of statuses.
statusManager *statusManager statusManager *statusManager
//Cloud provider interface
cloud cloudprovider.Interface
} }
// getRootDir returns the full path to the directory under which kubelet can // getRootDir returns the full path to the directory under which kubelet can