mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 04:52:08 +00:00
Merge pull request #8083 from brendandburns/kubectl
Add a flag to disable legacy APIs
This commit is contained in:
commit
3d31883829
@ -242,6 +242,11 @@ func (s *APIServer) Run(_ []string) error {
|
|||||||
|
|
||||||
_, enableV1 := s.RuntimeConfig["api/v1"]
|
_, enableV1 := s.RuntimeConfig["api/v1"]
|
||||||
|
|
||||||
|
disableLegacyAPIs := false
|
||||||
|
legacyAPIFlagValue, ok := s.RuntimeConfig["api/legacy"]
|
||||||
|
if ok && legacyAPIFlagValue == "false" {
|
||||||
|
disableLegacyAPIs = true
|
||||||
|
}
|
||||||
// TODO: expose same flags as client.BindClientConfigFlags but for a server
|
// TODO: expose same flags as client.BindClientConfigFlags but for a server
|
||||||
clientConfig := &client.Config{
|
clientConfig := &client.Config{
|
||||||
Host: net.JoinHostPort(s.InsecureBindAddress.String(), strconv.Itoa(s.InsecurePort)),
|
Host: net.JoinHostPort(s.InsecureBindAddress.String(), strconv.Itoa(s.InsecurePort)),
|
||||||
@ -324,6 +329,7 @@ func (s *APIServer) Run(_ []string) error {
|
|||||||
SupportsBasicAuth: len(s.BasicAuthFile) > 0,
|
SupportsBasicAuth: len(s.BasicAuthFile) > 0,
|
||||||
Authorizer: authorizer,
|
Authorizer: authorizer,
|
||||||
AdmissionControl: admissionController,
|
AdmissionControl: admissionController,
|
||||||
|
DisableLegacyAPIs: disableLegacyAPIs,
|
||||||
DisableV1Beta3: disableV1beta3,
|
DisableV1Beta3: disableV1beta3,
|
||||||
EnableV1: enableV1,
|
EnableV1: enableV1,
|
||||||
MasterServiceNamespace: s.MasterServiceNamespace,
|
MasterServiceNamespace: s.MasterServiceNamespace,
|
||||||
|
@ -91,6 +91,8 @@ type Config struct {
|
|||||||
EnableUISupport bool
|
EnableUISupport bool
|
||||||
// allow downstream consumers to disable swagger
|
// allow downstream consumers to disable swagger
|
||||||
EnableSwaggerSupport bool
|
EnableSwaggerSupport bool
|
||||||
|
// allow v1beta1 and v1beta2 to be conditionally disabled
|
||||||
|
DisableLegacyAPIs bool
|
||||||
// allow v1beta3 to be conditionally disabled
|
// allow v1beta3 to be conditionally disabled
|
||||||
DisableV1Beta3 bool
|
DisableV1Beta3 bool
|
||||||
// allow v1 to be conditionally enabled
|
// allow v1 to be conditionally enabled
|
||||||
@ -159,6 +161,7 @@ type Master struct {
|
|||||||
authorizer authorizer.Authorizer
|
authorizer authorizer.Authorizer
|
||||||
admissionControl admission.Interface
|
admissionControl admission.Interface
|
||||||
masterCount int
|
masterCount int
|
||||||
|
legacyAPIs bool
|
||||||
v1beta3 bool
|
v1beta3 bool
|
||||||
v1 bool
|
v1 bool
|
||||||
requestContextMapper api.RequestContextMapper
|
requestContextMapper api.RequestContextMapper
|
||||||
@ -303,6 +306,7 @@ func New(c *Config) *Master {
|
|||||||
authenticator: c.Authenticator,
|
authenticator: c.Authenticator,
|
||||||
authorizer: c.Authorizer,
|
authorizer: c.Authorizer,
|
||||||
admissionControl: c.AdmissionControl,
|
admissionControl: c.AdmissionControl,
|
||||||
|
legacyAPIs: !c.DisableLegacyAPIs,
|
||||||
v1beta3: !c.DisableV1Beta3,
|
v1beta3: !c.DisableV1Beta3,
|
||||||
v1: c.EnableV1,
|
v1: c.EnableV1,
|
||||||
requestContextMapper: c.RequestContextMapper,
|
requestContextMapper: c.RequestContextMapper,
|
||||||
@ -457,12 +461,16 @@ func (m *Master) init(c *Config) {
|
|||||||
"componentStatuses": componentstatus.NewStorage(func() map[string]apiserver.Server { return m.getServersToValidate(c, false) }),
|
"componentStatuses": componentstatus.NewStorage(func() map[string]apiserver.Server { return m.getServersToValidate(c, false) }),
|
||||||
}
|
}
|
||||||
|
|
||||||
apiVersions := []string{"v1beta1", "v1beta2"}
|
apiVersions := []string{}
|
||||||
if err := m.api_v1beta1().InstallREST(m.handlerContainer); err != nil {
|
if m.legacyAPIs {
|
||||||
glog.Fatalf("Unable to setup API v1beta1: %v", err)
|
if err := m.api_v1beta1().InstallREST(m.handlerContainer); err != nil {
|
||||||
}
|
glog.Fatalf("Unable to setup API v1beta1: %v", err)
|
||||||
if err := m.api_v1beta2().InstallREST(m.handlerContainer); err != nil {
|
}
|
||||||
glog.Fatalf("Unable to setup API v1beta2: %v", err)
|
apiVersions = append(apiVersions, "v1beta1")
|
||||||
|
if err := m.api_v1beta2().InstallREST(m.handlerContainer); err != nil {
|
||||||
|
glog.Fatalf("Unable to setup API v1beta2: %v", err)
|
||||||
|
}
|
||||||
|
apiVersions = append(apiVersions, "v1beta2")
|
||||||
}
|
}
|
||||||
if m.v1beta3 {
|
if m.v1beta3 {
|
||||||
if err := m.api_v1beta3().InstallREST(m.handlerContainer); err != nil {
|
if err := m.api_v1beta3().InstallREST(m.handlerContainer); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user