cmd/kube-apiserver: move back master count variable from generic controlplane
This commit is contained in:
		@@ -58,6 +58,8 @@ type Extra struct {
 | 
				
			|||||||
	ServiceNodePortRange utilnet.PortRange
 | 
						ServiceNodePortRange utilnet.PortRange
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	EndpointReconcilerType string
 | 
						EndpointReconcilerType string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						MasterCount int
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewServerRunOptions creates a new ServerRunOptions object with default parameters
 | 
					// NewServerRunOptions creates a new ServerRunOptions object with default parameters
 | 
				
			||||||
@@ -86,6 +88,7 @@ func NewServerRunOptions() *ServerRunOptions {
 | 
				
			|||||||
				HTTPTimeout: time.Duration(5) * time.Second,
 | 
									HTTPTimeout: time.Duration(5) * time.Second,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			ServiceNodePortRange: kubeoptions.DefaultServiceNodePortRange,
 | 
								ServiceNodePortRange: kubeoptions.DefaultServiceNodePortRange,
 | 
				
			||||||
 | 
								MasterCount:          1,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -146,5 +149,9 @@ func (s *ServerRunOptions) Flags() (fss cliflag.NamedFlagSets) {
 | 
				
			|||||||
	fs.StringVar(&s.KubeletConfig.TLSClientConfig.CAFile, "kubelet-certificate-authority", s.KubeletConfig.TLSClientConfig.CAFile,
 | 
						fs.StringVar(&s.KubeletConfig.TLSClientConfig.CAFile, "kubelet-certificate-authority", s.KubeletConfig.TLSClientConfig.CAFile,
 | 
				
			||||||
		"Path to a cert file for the certificate authority.")
 | 
							"Path to a cert file for the certificate authority.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fs.IntVar(&s.MasterCount, "apiserver-count", s.MasterCount,
 | 
				
			||||||
 | 
							"The number of apiservers running in the cluster, must be a positive number. (In use when --endpoint-reconciler-type=master-count is enabled.)")
 | 
				
			||||||
 | 
						fs.MarkDeprecated("apiserver-count", "apiserver-count is deprecated and will be removed in a future version.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return fss
 | 
						return fss
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -127,7 +127,6 @@ func TestAddFlags(t *testing.T) {
 | 
				
			|||||||
	// This is a snapshot of expected options parsed by args.
 | 
						// This is a snapshot of expected options parsed by args.
 | 
				
			||||||
	expected := &ServerRunOptions{
 | 
						expected := &ServerRunOptions{
 | 
				
			||||||
		Options: &controlplaneapiserver.Options{
 | 
							Options: &controlplaneapiserver.Options{
 | 
				
			||||||
			MasterCount: 5,
 | 
					 | 
				
			||||||
			GenericServerRunOptions: &apiserveroptions.ServerRunOptions{
 | 
								GenericServerRunOptions: &apiserveroptions.ServerRunOptions{
 | 
				
			||||||
				AdvertiseAddress:            netutils.ParseIPSloppy("192.168.10.10"),
 | 
									AdvertiseAddress:            netutils.ParseIPSloppy("192.168.10.10"),
 | 
				
			||||||
				CorsAllowedOriginList:       []string{"10.10.10.100", "10.10.10.200"},
 | 
									CorsAllowedOriginList:       []string{"10.10.10.100", "10.10.10.200"},
 | 
				
			||||||
@@ -320,6 +319,7 @@ func TestAddFlags(t *testing.T) {
 | 
				
			|||||||
					CAFile:   "/var/run/kubernetes/caserver.crt",
 | 
										CAFile:   "/var/run/kubernetes/caserver.crt",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								MasterCount: 5,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		CloudProvider: &kubeoptions.CloudProviderOptions{
 | 
							CloudProvider: &kubeoptions.CloudProviderOptions{
 | 
				
			||||||
			CloudConfigFile: "/cloud-config",
 | 
								CloudConfigFile: "/cloud-config",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -110,5 +110,9 @@ func (s CompletedOptions) Validate() []error {
 | 
				
			|||||||
	errs = append(errs, validateClusterIPFlags(s.Extra)...)
 | 
						errs = append(errs, validateClusterIPFlags(s.Extra)...)
 | 
				
			||||||
	errs = append(errs, validateServiceNodePort(s.Extra)...)
 | 
						errs = append(errs, validateServiceNodePort(s.Extra)...)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if s.MasterCount <= 0 {
 | 
				
			||||||
 | 
							errs = append(errs, fmt.Errorf("--apiserver-count should be a positive number, but value '%d' provided", s.MasterCount))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return errs
 | 
						return errs
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -66,8 +66,6 @@ type Options struct {
 | 
				
			|||||||
	EnableAggregatorRouting             bool
 | 
						EnableAggregatorRouting             bool
 | 
				
			||||||
	AggregatorRejectForwardingRedirects bool
 | 
						AggregatorRejectForwardingRedirects bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	MasterCount int
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ServiceAccountSigningKeyFile     string
 | 
						ServiceAccountSigningKeyFile     string
 | 
				
			||||||
	ServiceAccountIssuer             serviceaccount.TokenGenerator
 | 
						ServiceAccountIssuer             serviceaccount.TokenGenerator
 | 
				
			||||||
	ServiceAccountTokenMaxExpiration time.Duration
 | 
						ServiceAccountTokenMaxExpiration time.Duration
 | 
				
			||||||
@@ -104,7 +102,6 @@ func NewOptions() *Options {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		EnableLogsHandler:                   true,
 | 
							EnableLogsHandler:                   true,
 | 
				
			||||||
		EventTTL:                            1 * time.Hour,
 | 
							EventTTL:                            1 * time.Hour,
 | 
				
			||||||
		MasterCount:                         1,
 | 
					 | 
				
			||||||
		AggregatorRejectForwardingRedirects: true,
 | 
							AggregatorRejectForwardingRedirects: true,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -144,10 +141,6 @@ func (s *Options) AddFlags(fss *cliflag.NamedFlagSets) {
 | 
				
			|||||||
		"If non-zero, throttle each user connection to this number of bytes/sec. "+
 | 
							"If non-zero, throttle each user connection to this number of bytes/sec. "+
 | 
				
			||||||
		"Currently only applies to long-running requests.")
 | 
							"Currently only applies to long-running requests.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fs.IntVar(&s.MasterCount, "apiserver-count", s.MasterCount,
 | 
					 | 
				
			||||||
		"The number of apiservers running in the cluster, must be a positive number. (In use when --endpoint-reconciler-type=master-count is enabled.)")
 | 
					 | 
				
			||||||
	fs.MarkDeprecated("apiserver-count", "apiserver-count is deprecated and will be removed in a future version.")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	fs.StringVar(&s.ProxyClientCertFile, "proxy-client-cert-file", s.ProxyClientCertFile, ""+
 | 
						fs.StringVar(&s.ProxyClientCertFile, "proxy-client-cert-file", s.ProxyClientCertFile, ""+
 | 
				
			||||||
		"Client certificate used to prove the identity of the aggregator or kube-apiserver "+
 | 
							"Client certificate used to prove the identity of the aggregator or kube-apiserver "+
 | 
				
			||||||
		"when it must call out during a request. This includes proxying requests to a user "+
 | 
							"when it must call out during a request. This includes proxying requests to a user "+
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -54,7 +54,6 @@ func TestAddFlags(t *testing.T) {
 | 
				
			|||||||
		"--admission-control-config-file=/admission-control-config",
 | 
							"--admission-control-config-file=/admission-control-config",
 | 
				
			||||||
		"--advertise-address=192.168.10.10",
 | 
							"--advertise-address=192.168.10.10",
 | 
				
			||||||
		"--anonymous-auth=false",
 | 
							"--anonymous-auth=false",
 | 
				
			||||||
		"--apiserver-count=5",
 | 
					 | 
				
			||||||
		"--audit-log-maxage=11",
 | 
							"--audit-log-maxage=11",
 | 
				
			||||||
		"--audit-log-maxbackup=12",
 | 
							"--audit-log-maxbackup=12",
 | 
				
			||||||
		"--audit-log-maxsize=13",
 | 
							"--audit-log-maxsize=13",
 | 
				
			||||||
@@ -114,7 +113,6 @@ func TestAddFlags(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// This is a snapshot of expected options parsed by args.
 | 
						// This is a snapshot of expected options parsed by args.
 | 
				
			||||||
	expected := &Options{
 | 
						expected := &Options{
 | 
				
			||||||
		MasterCount: 5,
 | 
					 | 
				
			||||||
		GenericServerRunOptions: &apiserveroptions.ServerRunOptions{
 | 
							GenericServerRunOptions: &apiserveroptions.ServerRunOptions{
 | 
				
			||||||
			AdvertiseAddress:            netutils.ParseIPSloppy("192.168.10.10"),
 | 
								AdvertiseAddress:            netutils.ParseIPSloppy("192.168.10.10"),
 | 
				
			||||||
			CorsAllowedOriginList:       []string{"10.10.10.100", "10.10.10.200"},
 | 
								CorsAllowedOriginList:       []string{"10.10.10.100", "10.10.10.200"},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -72,9 +72,7 @@ func validateAPIPriorityAndFairness(options *Options) []error {
 | 
				
			|||||||
// Validate checks Options and return a slice of found errs.
 | 
					// Validate checks Options and return a slice of found errs.
 | 
				
			||||||
func (s *Options) Validate() []error {
 | 
					func (s *Options) Validate() []error {
 | 
				
			||||||
	var errs []error
 | 
						var errs []error
 | 
				
			||||||
	if s.MasterCount <= 0 {
 | 
					
 | 
				
			||||||
		errs = append(errs, fmt.Errorf("--apiserver-count should be a positive number, but value '%d' provided", s.MasterCount))
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	errs = append(errs, s.Etcd.Validate()...)
 | 
						errs = append(errs, s.Etcd.Validate()...)
 | 
				
			||||||
	errs = append(errs, validateAPIPriorityAndFairness(s)...)
 | 
						errs = append(errs, validateAPIPriorityAndFairness(s)...)
 | 
				
			||||||
	errs = append(errs, s.SecureServing.Validate()...)
 | 
						errs = append(errs, s.SecureServing.Validate()...)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -90,7 +90,6 @@ func TestValidateOptions(t *testing.T) {
 | 
				
			|||||||
			name:         "validate master count equal 0",
 | 
								name:         "validate master count equal 0",
 | 
				
			||||||
			expectErrors: true,
 | 
								expectErrors: true,
 | 
				
			||||||
			options: &Options{
 | 
								options: &Options{
 | 
				
			||||||
				MasterCount:             0,
 | 
					 | 
				
			||||||
				GenericServerRunOptions: &genericoptions.ServerRunOptions{},
 | 
									GenericServerRunOptions: &genericoptions.ServerRunOptions{},
 | 
				
			||||||
				Etcd:                    &genericoptions.EtcdOptions{},
 | 
									Etcd:                    &genericoptions.EtcdOptions{},
 | 
				
			||||||
				SecureServing:           &genericoptions.SecureServingOptionsWithLoopback{},
 | 
									SecureServing:           &genericoptions.SecureServingOptionsWithLoopback{},
 | 
				
			||||||
@@ -117,7 +116,6 @@ func TestValidateOptions(t *testing.T) {
 | 
				
			|||||||
			name:         "validate token request enable not attempted",
 | 
								name:         "validate token request enable not attempted",
 | 
				
			||||||
			expectErrors: true,
 | 
								expectErrors: true,
 | 
				
			||||||
			options: &Options{
 | 
								options: &Options{
 | 
				
			||||||
				MasterCount:             1,
 | 
					 | 
				
			||||||
				GenericServerRunOptions: &genericoptions.ServerRunOptions{},
 | 
									GenericServerRunOptions: &genericoptions.ServerRunOptions{},
 | 
				
			||||||
				Etcd:                    &genericoptions.EtcdOptions{},
 | 
									Etcd:                    &genericoptions.EtcdOptions{},
 | 
				
			||||||
				SecureServing:           &genericoptions.SecureServingOptionsWithLoopback{},
 | 
									SecureServing:           &genericoptions.SecureServingOptionsWithLoopback{},
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user