kubernetes/cmd/controller-manager/controller-manager.go
Kelsey Hightower dc7ee7c333 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.
2014-07-20 07:48:47 -07:00

63 lines
1.9 KiB
Go

/*
Copyright 2014 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// The controller manager is responsible for monitoring replication controllers, and creating corresponding
// pods to achieve the desired state. It listens for new controllers in etcd, and it sends requests to the
// master to create/delete pods.
//
// TODO: Refactor the etcd watch code so that it is a pluggable interface.
package main
import (
"flag"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/controller"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/coreos/go-etcd/etcd"
"github.com/golang/glog"
)
var (
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(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(etcdServerList),
client.New("http://"+*master, nil))
controllerManager.Run(10 * time.Second)
select {}
}