Esempio n. 1
0
func main() {
	leaderElection := kube_leaderelection.DefaultLeaderElectionConfiguration()
	leaderElection.LeaderElect = true

	kube_leaderelection.BindFlags(&leaderElection, pflag.CommandLine)
	flag.Var(&nodeGroupsFlag, "nodes", "sets min,max size and other configuration data for a node group in a format accepted by cloud provider."+
		"Can be used multiple times. Format: <min>:<max>:<other...>")
	kube_flag.InitFlags()

	glog.Infof("Cluster Autoscaler %s", ClusterAutoscalerVersion)

	correctEstimator := false
	for _, availableEstimator := range AvailableEstimators {
		if *estimatorFlag == availableEstimator {
			correctEstimator = true
		}
	}
	if !correctEstimator {
		glog.Fatalf("Unrecognized estimator: %v", *estimatorFlag)
	}

	go func() {
		http.Handle("/metrics", prometheus.Handler())
		err := http.ListenAndServe(*address, nil)
		glog.Fatalf("Failed to start metrics: %v", err)
	}()

	if !leaderElection.LeaderElect {
		run(nil)
	} else {
		id, err := os.Hostname()
		if err != nil {
			glog.Fatalf("Unable to get hostname: %v", err)
		}

		kubeClient := createKubeClient()
		kube_leaderelection.RunOrDie(kube_leaderelection.LeaderElectionConfig{
			Lock: &resourcelock.EndpointsLock{
				EndpointsMeta: apiv1.ObjectMeta{
					Namespace: "kube-system",
					Name:      "cluster-autoscaler",
				},
				Client: kubeClient,
				LockConfig: resourcelock.ResourceLockConfig{
					Identity:      id,
					EventRecorder: createEventRecorder(kubeClient),
				},
			},
			LeaseDuration: leaderElection.LeaseDuration.Duration,
			RenewDeadline: leaderElection.RenewDeadline.Duration,
			RetryPeriod:   leaderElection.RetryPeriod.Duration,
			Callbacks: kube_leaderelection.LeaderCallbacks{
				OnStartedLeading: run,
				OnStoppedLeading: func() {
					glog.Fatalf("lost master")
				},
			},
		})
	}
}
Esempio n. 2
0
// NewCMServer creates a new CMServer with a default config.
func NewCMServer() *CMServer {
	s := CMServer{
		Address:         net.ParseIP("0.0.0.0"),
		ClusterName:     "kubernetes",
		KubeAPIQPS:      20.0,
		KubeAPIBurst:    30,
		MinResyncPeriod: 12 * time.Hour,
		Port:            ports.ControllerManagerPort,

		NodeSyncPeriod: 10 * time.Second,

		LeaderElection:                    leaderelection.DefaultLeaderElectionConfiguration(),
		DeploymentControllerOptions:       deploymentoptions.NewDeploymentControllerOptions(),
		DaemonControllerOptions:           daemonoptions.NewDaemonControllerOptions(),
		EndpointControllerOptions:         endpointoptions.NewEndpointControllerOptions(),
		GarbageCollectorOptions:           gcoptions.NewGarbageCollectorOptions(),
		JobControllerOptions:              joboptions.NewJobControllerOptions(),
		NamespaceControllerOptions:        namespaceoptions.NewNamespaceControllerOptions(),
		NodeControllerOptions:             nodeoptions.NewNodeControllerOptions(),
		PersistentVolumeControllerOptions: pvoptions.NewPersistentVolumeControllerOptions(),
		PodAutoscalerOptions:              hpaoptions.NewPodAutoscalerOptions(),
		ReplicationControllerOptions:      replicationoptions.NewReplicationControllerOptions(),
		ResourceQuotaControllerOptions:    resourcequotaoptions.NewResourceQuotaControllerOptions(),
		ServiceControllerOptions:          serviceoptions.NewServiceControllerOptions(),
		ServiceAccountControllerOptions:   serviceaccountoptions.NewServiceAccountControllerOptions(),
	}
	return &s
}
Esempio n. 3
0
// NewCMServer creates a new CMServer with a default config.
func NewCMServer() *CMServer {
	s := CMServer{
		KubeControllerManagerConfiguration: componentconfig.KubeControllerManagerConfiguration{
			Port:                              ports.ControllerManagerPort,
			Address:                           "0.0.0.0",
			ConcurrentEndpointSyncs:           5,
			ConcurrentRCSyncs:                 5,
			ConcurrentRSSyncs:                 5,
			ConcurrentDaemonSetSyncs:          2,
			ConcurrentJobSyncs:                5,
			ConcurrentResourceQuotaSyncs:      5,
			ConcurrentDeploymentSyncs:         5,
			ConcurrentNamespaceSyncs:          2,
			ConcurrentSATokenSyncs:            5,
			LookupCacheSizeForRC:              4096,
			LookupCacheSizeForRS:              4096,
			LookupCacheSizeForDaemonSet:       1024,
			ServiceSyncPeriod:                 unversioned.Duration{Duration: 5 * time.Minute},
			NodeSyncPeriod:                    unversioned.Duration{Duration: 10 * time.Second},
			ResourceQuotaSyncPeriod:           unversioned.Duration{Duration: 5 * time.Minute},
			NamespaceSyncPeriod:               unversioned.Duration{Duration: 5 * time.Minute},
			PVClaimBinderSyncPeriod:           unversioned.Duration{Duration: 15 * time.Second},
			HorizontalPodAutoscalerSyncPeriod: unversioned.Duration{Duration: 30 * time.Second},
			DeploymentControllerSyncPeriod:    unversioned.Duration{Duration: 30 * time.Second},
			MinResyncPeriod:                   unversioned.Duration{Duration: 12 * time.Hour},
			RegisterRetryCount:                10,
			PodEvictionTimeout:                unversioned.Duration{Duration: 5 * time.Minute},
			NodeMonitorGracePeriod:            unversioned.Duration{Duration: 40 * time.Second},
			NodeStartupGracePeriod:            unversioned.Duration{Duration: 60 * time.Second},
			NodeMonitorPeriod:                 unversioned.Duration{Duration: 5 * time.Second},
			ClusterName:                       "kubernetes",
			NodeCIDRMaskSize:                  24,
			ConfigureCloudRoutes:              true,
			TerminatedPodGCThreshold:          12500,
			VolumeConfiguration: componentconfig.VolumeConfiguration{
				EnableHostPathProvisioning: false,
				EnableDynamicProvisioning:  true,
				PersistentVolumeRecyclerConfiguration: componentconfig.PersistentVolumeRecyclerConfiguration{
					MaximumRetry:             3,
					MinimumTimeoutNFS:        300,
					IncrementTimeoutNFS:      30,
					MinimumTimeoutHostPath:   60,
					IncrementTimeoutHostPath: 30,
				},
				FlexVolumePluginDir: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec/",
			},
			ContentType:             "application/vnd.kubernetes.protobuf",
			KubeAPIQPS:              20.0,
			KubeAPIBurst:            30,
			LeaderElection:          leaderelection.DefaultLeaderElectionConfiguration(),
			ControllerStartInterval: unversioned.Duration{Duration: 0 * time.Second},
			EnableGarbageCollector:  false,
			ConcurrentGCSyncs:       5,
			ClusterSigningCertFile:  "/etc/kubernetes/ca/ca.pem",
			ClusterSigningKeyFile:   "/etc/kubernetes/ca/ca.key",
		},
	}
	s.LeaderElection.LeaderElect = true
	return &s
}
Esempio n. 4
0
// NewSchedulerServer creates a new SchedulerServer with default parameters
func NewSchedulerServer() *SchedulerServer {
	s := SchedulerServer{
		Port:              ports.SchedulerPort,
		Address:           net.ParseIP("0.0.0.0"),
		AlgorithmProvider: factory.DefaultProvider,
		KubeAPIQPS:        50.0,
		KubeAPIBurst:      100,
		SchedulerName:     api.DefaultSchedulerName,
		LeaderElection:    leaderelection.DefaultLeaderElectionConfiguration(),
	}
	return &s
}
Esempio n. 5
0
// NewCMServer creates a new CMServer with a default config.
func NewCMServer() *CMServer {
	s := CMServer{
		ControllerManagerConfiguration: ControllerManagerConfiguration{
			Port:                 FederatedControllerManagerPort,
			Address:              "0.0.0.0",
			ClusterMonitorPeriod: unversioned.Duration{Duration: 40 * time.Second},
			APIServerQPS:         20.0,
			APIServerBurst:       30,
			LeaderElection:       leaderelection.DefaultLeaderElectionConfiguration(),
		},
	}
	return &s
}
Esempio n. 6
0
// NewCMServer creates a new CMServer with a default config.
func NewCMServer() *CMServer {
	s := CMServer{
		KubeControllerManagerConfiguration: componentconfig.KubeControllerManagerConfiguration{
			Port:                              ports.ControllerManagerPort,
			Address:                           "0.0.0.0",
			ConcurrentEndpointSyncs:           5,
			ConcurrentRCSyncs:                 5,
			ConcurrentRSSyncs:                 5,
			ConcurrentDaemonSetSyncs:          2,
			ConcurrentJobSyncs:                5,
			ConcurrentResourceQuotaSyncs:      5,
			ConcurrentDeploymentSyncs:         5,
			ConcurrentNamespaceSyncs:          2,
			ConcurrentSATokenSyncs:            5,
			LookupCacheSizeForRC:              4096,
			LookupCacheSizeForRS:              4096,
			LookupCacheSizeForDaemonSet:       1024,
			ServiceSyncPeriod:                 unversioned.Duration{Duration: 5 * time.Minute},
			NodeSyncPeriod:                    unversioned.Duration{Duration: 10 * time.Second},
			ResourceQuotaSyncPeriod:           unversioned.Duration{Duration: 5 * time.Minute},
			NamespaceSyncPeriod:               unversioned.Duration{Duration: 5 * time.Minute},
			PVClaimBinderSyncPeriod:           unversioned.Duration{Duration: 10 * time.Minute},
			HorizontalPodAutoscalerSyncPeriod: unversioned.Duration{Duration: 30 * time.Second},
			DeploymentControllerSyncPeriod:    unversioned.Duration{Duration: 30 * time.Second},
			MinResyncPeriod:                   unversioned.Duration{Duration: 12 * time.Hour},
			RegisterRetryCount:                10,
			PodEvictionTimeout:                unversioned.Duration{Duration: 5 * time.Minute},
			NodeMonitorGracePeriod:            unversioned.Duration{Duration: 40 * time.Second},
			NodeStartupGracePeriod:            unversioned.Duration{Duration: 60 * time.Second},
			NodeMonitorPeriod:                 unversioned.Duration{Duration: 5 * time.Second},
			ClusterName:                       "kubernetes",
			TerminatedPodGCThreshold:          12500,
			VolumeConfiguration: componentconfig.VolumeConfiguration{
				EnableHostPathProvisioning: false,
				PersistentVolumeRecyclerConfiguration: componentconfig.PersistentVolumeRecyclerConfiguration{
					MaximumRetry:             3,
					MinimumTimeoutNFS:        300,
					IncrementTimeoutNFS:      30,
					MinimumTimeoutHostPath:   60,
					IncrementTimeoutHostPath: 30,
				},
			},
			KubeAPIQPS:              20.0,
			KubeAPIBurst:            30,
			LeaderElection:          leaderelection.DefaultLeaderElectionConfiguration(),
			ControllerStartInterval: unversioned.Duration{Duration: 0 * time.Second},
		},
	}
	return &s
}
Esempio n. 7
0
// NewSchedulerServer creates a new SchedulerServer with default parameters
func NewSchedulerServer() *SchedulerServer {
	s := SchedulerServer{
		KubeSchedulerConfiguration: componentconfig.KubeSchedulerConfiguration{
			Port:              ports.SchedulerPort,
			Address:           "0.0.0.0",
			AlgorithmProvider: factory.DefaultProvider,
			KubeAPIQPS:        50.0,
			KubeAPIBurst:      100,
			SchedulerName:     api.DefaultSchedulerName,
			LeaderElection:    leaderelection.DefaultLeaderElectionConfiguration(),
		},
	}
	return &s
}
Esempio n. 8
0
// NewCMServer creates a new CMServer with a default config.
func NewCMServer() *CMServer {
	s := CMServer{
		ControllerManagerConfiguration: ControllerManagerConfiguration{
			Port:                      FederatedControllerManagerPort,
			Address:                   "0.0.0.0",
			ConcurrentServiceSyncs:    10,
			ConcurrentReplicaSetSyncs: 10,
			ClusterMonitorPeriod:      metav1.Duration{Duration: 40 * time.Second},
			APIServerQPS:              20.0,
			APIServerBurst:            30,
			LeaderElection:            leaderelection.DefaultLeaderElectionConfiguration(),
		},
	}
	return &s
}
Esempio n. 9
0
// NewCMServer creates a new CMServer with a default config.
func NewCMServer() *CMServer {
	s := CMServer{
		Port:                              ports.ControllerManagerPort,
		Address:                           net.ParseIP("0.0.0.0"),
		ConcurrentEndpointSyncs:           5,
		ConcurrentRCSyncs:                 5,
		ConcurrentRSSyncs:                 5,
		ConcurrentDSCSyncs:                2,
		ConcurrentJobSyncs:                5,
		ConcurrentResourceQuotaSyncs:      5,
		ConcurrentDeploymentSyncs:         5,
		ConcurrentNamespaceSyncs:          2,
		ServiceSyncPeriod:                 5 * time.Minute,
		NodeSyncPeriod:                    10 * time.Second,
		ResourceQuotaSyncPeriod:           5 * time.Minute,
		NamespaceSyncPeriod:               5 * time.Minute,
		PVClaimBinderSyncPeriod:           10 * time.Minute,
		HorizontalPodAutoscalerSyncPeriod: 30 * time.Second,
		DeploymentControllerSyncPeriod:    30 * time.Second,
		MinResyncPeriod:                   12 * time.Hour,
		RegisterRetryCount:                10,
		PodEvictionTimeout:                5 * time.Minute,
		NodeMonitorGracePeriod:            40 * time.Second,
		NodeStartupGracePeriod:            60 * time.Second,
		NodeMonitorPeriod:                 5 * time.Second,
		ClusterName:                       "kubernetes",
		TerminatedPodGCThreshold:          12500,
		VolumeConfigFlags: VolumeConfigFlags{
			// default values here
			PersistentVolumeRecyclerMaximumRetry:             3,
			PersistentVolumeRecyclerMinimumTimeoutNFS:        300,
			PersistentVolumeRecyclerIncrementTimeoutNFS:      30,
			PersistentVolumeRecyclerMinimumTimeoutHostPath:   60,
			PersistentVolumeRecyclerIncrementTimeoutHostPath: 30,
			EnableHostPathProvisioning:                       false,
		},
		KubeAPIQPS:     20.0,
		KubeAPIBurst:   30,
		LeaderElection: leaderelection.DefaultLeaderElectionConfiguration(),
	}
	return &s
}
Esempio n. 10
0
// NewCloudControllerManagerServer creates a new ExternalCMServer with a default config.
func NewCloudControllerManagerServer() *CloudControllerManagerServer {
	s := CloudControllerManagerServer{
		KubeControllerManagerConfiguration: componentconfig.KubeControllerManagerConfiguration{
			Port:                    ports.CloudControllerManagerPort,
			Address:                 "0.0.0.0",
			ConcurrentServiceSyncs:  1,
			MinResyncPeriod:         metav1.Duration{Duration: 12 * time.Hour},
			NodeMonitorPeriod:       metav1.Duration{Duration: 5 * time.Second},
			ClusterName:             "kubernetes",
			ConfigureCloudRoutes:    true,
			ContentType:             "application/vnd.kubernetes.protobuf",
			KubeAPIQPS:              20.0,
			KubeAPIBurst:            30,
			LeaderElection:          leaderelection.DefaultLeaderElectionConfiguration(),
			ControllerStartInterval: metav1.Duration{Duration: 0 * time.Second},
		},
	}
	s.LeaderElection.LeaderElect = true
	return &s
}