mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-11-24 13:49:27 +00:00
Allow etcd config file to be passed to apiserver, kubelet, and proxy
This commit is contained in:
committed by
Haney Maxwell
parent
9c0fafee39
commit
4d87159eda
@@ -33,13 +33,14 @@ import (
|
||||
var (
|
||||
configFile = flag.String("configfile", "/tmp/proxy_config", "Configuration file for the proxy")
|
||||
etcdServerList util.StringList
|
||||
etcdConfigFile = flag.String("etcd_config", "", "The config file for the etcd client. Mutually exclusive with -etcd_servers")
|
||||
bindAddress = util.IP(net.ParseIP("0.0.0.0"))
|
||||
clientConfig = &client.Config{}
|
||||
)
|
||||
|
||||
func init() {
|
||||
client.BindClientConfigFlags(flag.CommandLine, clientConfig)
|
||||
flag.Var(&etcdServerList, "etcd_servers", "List of etcd servers to watch (http://ip:port), comma separated (optional)")
|
||||
flag.Var(&etcdServerList, "etcd_servers", "List of etcd servers to watch (http://ip:port), comma separated (optional). Mutually exclusive with -etcd_config")
|
||||
flag.Var(&bindAddress, "bind_address", "The address for the proxy server to serve on (set to 0.0.0.0 for all interfaces)")
|
||||
}
|
||||
|
||||
@@ -66,18 +67,34 @@ func main() {
|
||||
serviceConfig.Channel("api"),
|
||||
endpointsConfig.Channel("api"),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
|
||||
// Create a configuration source that handles configuration from etcd.
|
||||
if len(etcdServerList) > 0 && clientConfig.Host == "" {
|
||||
glog.Infof("Using etcd servers %v", etcdServerList)
|
||||
var etcdClient *etcd.Client
|
||||
|
||||
// Set up logger for etcd client
|
||||
etcd.SetLogger(util.NewLogger("etcd "))
|
||||
etcdClient := etcd.NewClient(etcdServerList)
|
||||
config.NewConfigSourceEtcd(etcdClient,
|
||||
serviceConfig.Channel("etcd"),
|
||||
endpointsConfig.Channel("etcd"))
|
||||
// Set up etcd client
|
||||
if len(etcdServerList) > 0 {
|
||||
// Set up logger for etcd client
|
||||
etcd.SetLogger(util.NewLogger("etcd "))
|
||||
etcdClient = etcd.NewClient(etcdServerList)
|
||||
} else if *etcdConfigFile != "" {
|
||||
// Set up logger for etcd client
|
||||
etcd.SetLogger(util.NewLogger("etcd "))
|
||||
var err error
|
||||
etcdClient, err = etcd.NewClientFromFile(*etcdConfigFile)
|
||||
|
||||
if err != nil {
|
||||
glog.Fatalf("Error with etcd config file: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Create a configuration source that handles configuration from etcd.
|
||||
if etcdClient != nil {
|
||||
glog.Infof("Using etcd servers %v", etcdClient.GetCluster())
|
||||
|
||||
config.NewConfigSourceEtcd(etcdClient,
|
||||
serviceConfig.Channel("etcd"),
|
||||
endpointsConfig.Channel("etcd"))
|
||||
}
|
||||
}
|
||||
|
||||
// And create a configuration source that reads from a local file
|
||||
|
||||
Reference in New Issue
Block a user