Skip to content

Commit

Permalink
Merge pull request kubernetes#536 from kelseyhightower/etcd_servers
Browse files Browse the repository at this point in the history
normalize -etcd_servers flag across all commands
  • Loading branch information
lavalamp committed Jul 20, 2014
2 parents 1e63719 + dc7ee7c commit 3398646
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cmd/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}

Expand Down
12 changes: 8 additions & 4 deletions cmd/controller-manager/controller-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,28 @@ 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 <servers> -master <master>")
}

// Set up logger for etcd client
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)
Expand Down
4 changes: 2 additions & 2 deletions cmd/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}
Expand Down
8 changes: 6 additions & 2 deletions cmd/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
}
12 changes: 8 additions & 4 deletions cmd/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"))
Expand Down
9 changes: 4 additions & 5 deletions pkg/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 != "" {
Expand Down

0 comments on commit 3398646

Please sign in to comment.