mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Added flags for horizontal pod autoscaler to controller-manager.
Added flags for horizontal pod autoscaler to controller-manager.
This commit is contained in:
		@@ -35,6 +35,7 @@ import (
 | 
			
		||||
	"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
 | 
			
		||||
	clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/cloudprovider"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/controller/autoscaler"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/controller/endpoint"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/controller/namespace"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/controller/node"
 | 
			
		||||
@@ -51,9 +52,6 @@ import (
 | 
			
		||||
	"github.com/golang/glog"
 | 
			
		||||
	"github.com/prometheus/client_golang/prometheus"
 | 
			
		||||
	"github.com/spf13/pflag"
 | 
			
		||||
 | 
			
		||||
	// TODO: Enable the code belowe when horizontal pod autoscaler controller is implemented.
 | 
			
		||||
	// "k8s.io/kubernetes/pkg/controller/autoscaler"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// CMServer is the main context object for the controller manager.
 | 
			
		||||
@@ -69,6 +67,7 @@ type CMServer struct {
 | 
			
		||||
	ResourceQuotaSyncPeriod           time.Duration
 | 
			
		||||
	NamespaceSyncPeriod               time.Duration
 | 
			
		||||
	PVClaimBinderSyncPeriod           time.Duration
 | 
			
		||||
	HorizontalPodAutoscalerSyncPeriod time.Duration
 | 
			
		||||
	RegisterRetryCount                int
 | 
			
		||||
	NodeMonitorGracePeriod            time.Duration
 | 
			
		||||
	NodeStartupGracePeriod            time.Duration
 | 
			
		||||
@@ -84,6 +83,7 @@ type CMServer struct {
 | 
			
		||||
	ClusterCIDR                   net.IPNet
 | 
			
		||||
	AllocateNodeCIDRs             bool
 | 
			
		||||
	EnableProfiling               bool
 | 
			
		||||
	EnableHorizontalPodAutoscaler bool
 | 
			
		||||
 | 
			
		||||
	Master     string
 | 
			
		||||
	Kubeconfig string
 | 
			
		||||
@@ -101,9 +101,11 @@ func NewCMServer() *CMServer {
 | 
			
		||||
		ResourceQuotaSyncPeriod:           10 * time.Second,
 | 
			
		||||
		NamespaceSyncPeriod:               5 * time.Minute,
 | 
			
		||||
		PVClaimBinderSyncPeriod:           10 * time.Second,
 | 
			
		||||
		HorizontalPodAutoscalerSyncPeriod: 1 * time.Minute,
 | 
			
		||||
		RegisterRetryCount:                10,
 | 
			
		||||
		PodEvictionTimeout:                5 * time.Minute,
 | 
			
		||||
		ClusterName:                       "kubernetes",
 | 
			
		||||
		EnableHorizontalPodAutoscaler:     false,
 | 
			
		||||
	}
 | 
			
		||||
	return &s
 | 
			
		||||
}
 | 
			
		||||
@@ -123,6 +125,7 @@ func (s *CMServer) AddFlags(fs *pflag.FlagSet) {
 | 
			
		||||
	fs.DurationVar(&s.ResourceQuotaSyncPeriod, "resource-quota-sync-period", s.ResourceQuotaSyncPeriod, "The period for syncing quota usage status in the system")
 | 
			
		||||
	fs.DurationVar(&s.NamespaceSyncPeriod, "namespace-sync-period", s.NamespaceSyncPeriod, "The period for syncing namespace life-cycle updates")
 | 
			
		||||
	fs.DurationVar(&s.PVClaimBinderSyncPeriod, "pvclaimbinder-sync-period", s.PVClaimBinderSyncPeriod, "The period for syncing persistent volumes and persistent volume claims")
 | 
			
		||||
	fs.DurationVar(&s.HorizontalPodAutoscalerSyncPeriod, "horizontal-pod-autoscaler-sync-period", s.HorizontalPodAutoscalerSyncPeriod, "The period for syncing the number of pods in horizontal pod autoscaler.")
 | 
			
		||||
	fs.DurationVar(&s.PodEvictionTimeout, "pod-eviction-timeout", s.PodEvictionTimeout, "The grace period for deleting pods on failed nodes.")
 | 
			
		||||
	fs.Float32Var(&s.DeletingPodsQps, "deleting-pods-qps", 0.1, "Number of nodes per second on which pods are deleted in case of node failure.")
 | 
			
		||||
	fs.IntVar(&s.DeletingPodsBurst, "deleting-pods-burst", 10, "Number of nodes on which pods are bursty deleted in case of node failure. For more details look into RateLimiter.")
 | 
			
		||||
@@ -145,6 +148,7 @@ func (s *CMServer) AddFlags(fs *pflag.FlagSet) {
 | 
			
		||||
	fs.StringVar(&s.Master, "master", s.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig)")
 | 
			
		||||
	fs.StringVar(&s.Kubeconfig, "kubeconfig", s.Kubeconfig, "Path to kubeconfig file with authorization and master location information.")
 | 
			
		||||
	fs.StringVar(&s.RootCAFile, "root-ca-file", s.RootCAFile, "If set, this root certificate authority will be included in service account's token secret. This must be a valid PEM-encoded CA bundle.")
 | 
			
		||||
	fs.BoolVar(&s.EnableHorizontalPodAutoscaler, "enable-horizontal-pod-autoscaler", s.EnableHorizontalPodAutoscaler, "Enables horizontal pod autoscaler (requires enabling experimental API on apiserver). NOT IMPLEMENTED YET!")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Run runs the CMServer.  This should never exit.
 | 
			
		||||
@@ -267,13 +271,14 @@ func (s *CMServer) Run(_ []string) error {
 | 
			
		||||
		serviceaccount.DefaultServiceAccountsControllerOptions(),
 | 
			
		||||
	).Run()
 | 
			
		||||
 | 
			
		||||
	// TODO: Enable the code belowe when horizontal pod autoscaler controller is implemented.
 | 
			
		||||
	// expClient, err := client.NewExperimental(kubeconfig)
 | 
			
		||||
	// if err != nil {
 | 
			
		||||
	// 	glog.Fatalf("Invalid API configuration: %v", err)
 | 
			
		||||
	// }
 | 
			
		||||
	// horizontalPodAutoscalerController := autoscalercontroller.New(kubeClient, expClient)
 | 
			
		||||
	// horizontalPodAutoscalerController.Run(s.NodeSyncPeriod)
 | 
			
		||||
	if s.EnableHorizontalPodAutoscaler {
 | 
			
		||||
		expClient, err := client.NewExperimental(kubeconfig)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			glog.Fatalf("Invalid API configuration: %v", err)
 | 
			
		||||
		}
 | 
			
		||||
		horizontalPodAutoscalerController := autoscalercontroller.New(kubeClient, expClient)
 | 
			
		||||
		horizontalPodAutoscalerController.Run(s.HorizontalPodAutoscalerSyncPeriod)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	select {}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -65,6 +65,7 @@ dry-run
 | 
			
		||||
duration-sec
 | 
			
		||||
e2e-output-dir
 | 
			
		||||
enable-debugging-handlers
 | 
			
		||||
enable-horizontal-pod-autoscaler
 | 
			
		||||
enable-server
 | 
			
		||||
etcd-config
 | 
			
		||||
etcd-prefix
 | 
			
		||||
@@ -96,6 +97,7 @@ grace-period
 | 
			
		||||
ha-domain
 | 
			
		||||
healthz-bind-address
 | 
			
		||||
healthz-port
 | 
			
		||||
horizontal-pod-autoscaler-sync-period
 | 
			
		||||
hostname-override
 | 
			
		||||
host-network-sources
 | 
			
		||||
http-check-frequency
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user