mirror of https://github.com/k3s-io/k3s
normalize -etcd_servers flag across all commands
The -etcd_servers flag is used inconsistently by the Kubernetes commands, both externally and internally. This patch fixes the issue by using the same type to represent a list of etcd servers internally, and declares the -etcd_servers flag consistently across all commands. This patch should be 100% backwards compatible with no changes in behavior.pull/6/head
parent
1e63719e02
commit
dc7ee7c333
|
@ -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.")
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <servers> -master <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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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"))
|
||||
|
|
|
@ -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 != "" {
|
||||
|
|
Loading…
Reference in New Issue