Add a use-real-cloud flag to allow the controller to run on the master
This commit is contained in:
parent
8084341920
commit
fe026b73f0
1 changed files with 19 additions and 28 deletions
|
@ -29,8 +29,6 @@ import (
|
||||||
flag "github.com/spf13/pflag"
|
flag "github.com/spf13/pflag"
|
||||||
"k8s.io/contrib/ingress/controllers/gce/controller"
|
"k8s.io/contrib/ingress/controllers/gce/controller"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
|
||||||
"k8s.io/kubernetes/pkg/client/restclient"
|
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||||
kubectl_util "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
kubectl_util "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||||
"k8s.io/kubernetes/pkg/util/wait"
|
"k8s.io/kubernetes/pkg/util/wait"
|
||||||
|
@ -58,7 +56,7 @@ const (
|
||||||
alphaNumericChar = "0"
|
alphaNumericChar = "0"
|
||||||
|
|
||||||
// Current docker image version. Only used in debug logging.
|
// Current docker image version. Only used in debug logging.
|
||||||
imageVersion = "glbc:0.6.1"
|
imageVersion = "glbc:0.6.2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -66,12 +64,6 @@ var (
|
||||||
`gclb: gclb --runngin-in-cluster=false --default-backend-node-port=123`,
|
`gclb: gclb --runngin-in-cluster=false --default-backend-node-port=123`,
|
||||||
flag.ExitOnError)
|
flag.ExitOnError)
|
||||||
|
|
||||||
proxyUrl = flags.String("proxy", "",
|
|
||||||
`If specified, the controller assumes a kubctl proxy server is running on the
|
|
||||||
given url and creates a proxy client and fake cluster manager. Results are
|
|
||||||
printed to stdout and no changes are made to your cluster. This flag is for
|
|
||||||
testing.`)
|
|
||||||
|
|
||||||
clusterName = flags.String("cluster-uid", controller.DefaultClusterUID,
|
clusterName = flags.String("cluster-uid", controller.DefaultClusterUID,
|
||||||
`Optional, used to tag cluster wide, shared loadbalancer resources such
|
`Optional, used to tag cluster wide, shared loadbalancer resources such
|
||||||
as instance groups. Use this flag if you'd like to continue using the
|
as instance groups. Use this flag if you'd like to continue using the
|
||||||
|
@ -83,6 +75,13 @@ var (
|
||||||
`Optional, if this controller is running in a kubernetes cluster, use the
|
`Optional, if this controller is running in a kubernetes cluster, use the
|
||||||
pod secrets for creating a Kubernetes client.`)
|
pod secrets for creating a Kubernetes client.`)
|
||||||
|
|
||||||
|
// TODO: Consolidate this flag and running-in-cluster. People already use
|
||||||
|
// the first one to mean "running in dev", unfortunately.
|
||||||
|
useRealCloud = flags.Bool("use-real-cloud", false,
|
||||||
|
`Optional, if set a real cloud client is created. Only matters with
|
||||||
|
--running-in-cluster=false, i.e a real cloud is always used when this
|
||||||
|
controller is running on a Kubernetes node.`)
|
||||||
|
|
||||||
resyncPeriod = flags.Duration("sync-period", 30*time.Second,
|
resyncPeriod = flags.Duration("sync-period", 30*time.Second,
|
||||||
`Relist and confirm cloud resources this often.`)
|
`Relist and confirm cloud resources this often.`)
|
||||||
|
|
||||||
|
@ -162,13 +161,6 @@ func main() {
|
||||||
glog.Fatalf("Please specify --default-backend")
|
glog.Fatalf("Please specify --default-backend")
|
||||||
}
|
}
|
||||||
|
|
||||||
if *proxyUrl != "" {
|
|
||||||
// Create proxy kubeclient
|
|
||||||
kubeClient = client.NewOrDie(&restclient.Config{
|
|
||||||
Host: *proxyUrl,
|
|
||||||
ContentConfig: restclient.ContentConfig{GroupVersion: &unversioned.GroupVersion{Version: "v1"}},
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
// Create kubeclient
|
// Create kubeclient
|
||||||
if *inCluster {
|
if *inCluster {
|
||||||
if kubeClient, err = client.NewInCluster(); err != nil {
|
if kubeClient, err = client.NewInCluster(); err != nil {
|
||||||
|
@ -181,7 +173,6 @@ func main() {
|
||||||
}
|
}
|
||||||
kubeClient, err = client.New(config)
|
kubeClient, err = client.New(config)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Wait for the default backend Service. There's no pretty way to do this.
|
// Wait for the default backend Service. There's no pretty way to do this.
|
||||||
parts := strings.Split(*defaultSvc, "/")
|
parts := strings.Split(*defaultSvc, "/")
|
||||||
if len(parts) != 2 {
|
if len(parts) != 2 {
|
||||||
|
@ -194,7 +185,7 @@ func main() {
|
||||||
*defaultSvc, err)
|
*defaultSvc, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *proxyUrl == "" && *inCluster {
|
if *inCluster || *useRealCloud {
|
||||||
// Create cluster manager
|
// Create cluster manager
|
||||||
clusterManager, err = controller.NewClusterManager(
|
clusterManager, err = controller.NewClusterManager(
|
||||||
*clusterName, defaultBackendNodePort, *healthCheckPath)
|
*clusterName, defaultBackendNodePort, *healthCheckPath)
|
||||||
|
|
Loading…
Reference in a new issue