diff --git a/cmd/apiserver/apiserver.go b/cmd/apiserver/apiserver.go index 5ed7b7da96a48..7f0603f805ffc 100644 --- a/cmd/apiserver/apiserver.go +++ b/cmd/apiserver/apiserver.go @@ -42,7 +42,7 @@ var ( ) func init() { - flag.Var(&etcdServerList, "etcd_servers", "Servers for the etcd (http://ip:port), comma separated") + flag.Var(&etcdServerList, "etcd_servers", "List of etcd servers to watch (http://ip:port), comma separated") flag.Var(&machineList, "machines", "List of machines to schedule onto, comma separated.") } diff --git a/cmd/controller-manager/controller-manager.go b/cmd/controller-manager/controller-manager.go index 787c5e0053fd8..1e537f45b97e3 100644 --- a/cmd/controller-manager/controller-manager.go +++ b/cmd/controller-manager/controller-manager.go @@ -33,16 +33,20 @@ import ( ) var ( - etcdServers = flag.String("etcd_servers", "", "Servers for the etcd (http://ip:port).") - master = flag.String("master", "", "The address of the Kubernetes API server") + etcdServerList util.StringList + master = flag.String("master", "", "The address of the Kubernetes API server") ) +func init() { + flag.Var(&etcdServerList, "etcd_servers", "List of etcd servers to watch (http://ip:port), comma separated") +} + func main() { flag.Parse() util.InitLogs() defer util.FlushLogs() - if len(*etcdServers) == 0 || len(*master) == 0 { + if len(etcdServerList) == 0 || len(*master) == 0 { glog.Fatal("usage: controller-manager -etcd_servers -master ") } @@ -50,7 +54,7 @@ func main() { etcd.SetLogger(util.NewLogger("etcd ")) controllerManager := controller.MakeReplicationManager( - etcd.NewClient([]string{*etcdServers}), + etcd.NewClient(etcdServerList), client.New("http://"+*master, nil)) controllerManager.Run(10 * time.Second) diff --git a/cmd/integration/integration.go b/cmd/integration/integration.go index 175c2ce9e4628..d16947e78ac87 100644 --- a/cmd/integration/integration.go +++ b/cmd/integration/integration.go @@ -106,7 +106,7 @@ func startComponents(manifestURL string) (apiServerURL string) { SyncFrequency: 5 * time.Second, HTTPCheckFrequency: 5 * time.Second, } - go myKubelet.RunKubelet("", "", manifestURL, servers[0], "localhost", 10250) + go myKubelet.RunKubelet("", "", manifestURL, servers, "localhost", 10250) // Create a second kubelet so that the guestbook example's two redis slaves both // have a place they can schedule. @@ -118,7 +118,7 @@ func startComponents(manifestURL string) (apiServerURL string) { SyncFrequency: 5 * time.Second, HTTPCheckFrequency: 5 * time.Second, } - go otherKubelet.RunKubelet("", "", "", servers[0], "localhost", 10251) + go otherKubelet.RunKubelet("", "", "", servers, "localhost", 10251) return apiserver.URL } diff --git a/cmd/kubelet/kubelet.go b/cmd/kubelet/kubelet.go index 844a7d40bff06..c570fcd99d77f 100644 --- a/cmd/kubelet/kubelet.go +++ b/cmd/kubelet/kubelet.go @@ -37,7 +37,6 @@ import ( var ( config = flag.String("config", "", "Path to the config file or directory of files") - etcdServers = flag.String("etcd_servers", "", "Url of etcd servers in the cluster") syncFrequency = flag.Duration("sync_frequency", 10*time.Second, "Max period between synchronizing running containers and config") fileCheckFrequency = flag.Duration("file_check_frequency", 20*time.Second, "Duration between checking config files for new data") httpCheckFrequency = flag.Duration("http_check_frequency", 20*time.Second, "Duration between checking http for new data") @@ -46,8 +45,13 @@ var ( port = flag.Uint("port", 10250, "The port for the info server to serve on") hostnameOverride = flag.String("hostname_override", "", "If non-empty, will use this string as identification instead of the actual hostname.") dockerEndpoint = flag.String("docker_endpoint", "", "If non-empty, use this for the docker endpoint to communicate with") + etcdServerList util.StringList ) +func init() { + flag.Var(&etcdServerList, "etcd_servers", "List of etcd servers to watch (http://ip:port), comma separated") +} + func getDockerEndpoint() string { var endpoint string if len(*dockerEndpoint) > 0 { @@ -96,5 +100,5 @@ func main() { SyncFrequency: *syncFrequency, HTTPCheckFrequency: *httpCheckFrequency, } - k.RunKubelet(*dockerEndpoint, *config, *manifestURL, *etcdServers, *address, *port) + k.RunKubelet(*dockerEndpoint, *config, *manifestURL, etcdServerList, *address, *port) } diff --git a/cmd/proxy/proxy.go b/cmd/proxy/proxy.go index 35b8f4d38b487..6e6ac24db06d2 100644 --- a/cmd/proxy/proxy.go +++ b/cmd/proxy/proxy.go @@ -27,10 +27,14 @@ import ( ) var ( - configFile = flag.String("configfile", "/tmp/proxy_config", "Configuration file for the proxy") - etcdServers = flag.String("etcd_servers", "http://10.240.10.57:4001", "Servers for the etcd cluster (http://ip:port).") + configFile = flag.String("configfile", "/tmp/proxy_config", "Configuration file for the proxy") + etcdServerList util.StringList ) +func init() { + flag.Var(&etcdServerList, "etcd_servers", "List of etcd servers to watch (http://ip:port), comma separated") +} + func main() { flag.Parse() util.InitLogs() @@ -39,13 +43,13 @@ func main() { // Set up logger for etcd client etcd.SetLogger(util.NewLogger("etcd ")) - glog.Infof("Using configuration file %s and etcd_servers %s", *configFile, *etcdServers) + glog.Infof("Using configuration file %s and etcd_servers %v", *configFile, etcdServerList) serviceConfig := config.NewServiceConfig() endpointsConfig := config.NewEndpointsConfig() // Create a configuration source that handles configuration from etcd. - etcdClient := etcd.NewClient([]string{*etcdServers}) + etcdClient := etcd.NewClient(etcdServerList) config.NewConfigSourceEtcd(etcdClient, serviceConfig.Channel("etcd"), endpointsConfig.Channel("etcd")) diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index 824297752ea49..3f7850b92aa1f 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -93,7 +93,7 @@ const ( // RunKubelet starts background goroutines. If config_path, manifest_url, or address are empty, // they are not watched. Never returns. -func (kl *Kubelet) RunKubelet(dockerEndpoint, configPath, manifestURL, etcdServers, address string, port uint) { +func (kl *Kubelet) RunKubelet(dockerEndpoint, configPath, manifestURL string, etcdServers []string, address string, port uint) { if kl.CadvisorClient == nil { var err error kl.CadvisorClient, err = cadvisor.NewClient("http://127.0.0.1:5000") @@ -119,10 +119,9 @@ func (kl *Kubelet) RunKubelet(dockerEndpoint, configPath, manifestURL, etcdServe } }, kl.HTTPCheckFrequency) } - if etcdServers != "" { - servers := []string{etcdServers} - glog.Infof("Watching for etcd configs at %v", servers) - kl.EtcdClient = etcd.NewClient(servers) + if len(etcdServers) > 0 { + glog.Infof("Watching for etcd configs at %v", etcdServers) + kl.EtcdClient = etcd.NewClient(etcdServers) go util.Forever(func() { kl.SyncAndSetupEtcdWatch(updateChannel) }, 20*time.Second) } if address != "" {