Merge pull request #10525 from nikhiljindal/delbeta3

Stop exposing v1beta3 by default
This commit is contained in:
Victor Marmol 2015-07-09 08:38:32 -07:00
commit edaa1a69e5
10 changed files with 73 additions and 45 deletions

View File

@ -152,6 +152,8 @@ func startComponents(firstManifestURL, secondManifestURL, apiVersion string) (st
glog.Fatalf("no public address for %s", host) glog.Fatalf("no public address for %s", host)
} }
// Enable v1beta3 in master only if we are starting the components for that api version.
enableV1Beta3 := apiVersion == "v1beta3"
// Create a master and install handlers into mux. // Create a master and install handlers into mux.
m := master.New(&master.Config{ m := master.New(&master.Config{
EtcdHelper: helper, EtcdHelper: helper,
@ -160,6 +162,7 @@ func startComponents(firstManifestURL, secondManifestURL, apiVersion string) (st
EnableLogsSupport: false, EnableLogsSupport: false,
EnableProfiling: true, EnableProfiling: true,
APIPrefix: "/api", APIPrefix: "/api",
EnableV1Beta3: enableV1Beta3,
Authorizer: apiserver.NewAlwaysAllowAuthorizer(), Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(), AdmissionControl: admit.NewAlwaysAdmit(),
ReadWritePort: portNumber, ReadWritePort: portNumber,

View File

@ -275,7 +275,6 @@ func (s *APIServer) Run(_ []string) error {
} }
// "api/legacy=false" allows users to disable legacy api versions. // "api/legacy=false" allows users to disable legacy api versions.
// Right now, v1beta1 and v1beta2 are considered legacy.
disableLegacyAPIs := false disableLegacyAPIs := false
legacyAPIFlagValue, ok := s.RuntimeConfig["api/legacy"] legacyAPIFlagValue, ok := s.RuntimeConfig["api/legacy"]
if ok && legacyAPIFlagValue == "false" { if ok && legacyAPIFlagValue == "false" {
@ -283,10 +282,8 @@ func (s *APIServer) Run(_ []string) error {
} }
_ = disableLegacyAPIs // hush the compiler while we don't have legacy APIs to disable. _ = disableLegacyAPIs // hush the compiler while we don't have legacy APIs to disable.
// "api/v1beta3={true|false} allows users to enable/disable v1beta3 API. // v1beta3 is disabled by default. Users can enable it using "api/v1beta3=true"
// This takes preference over api/all and api/legacy, if specified. enableV1beta3 := s.getRuntimeConfigValue("api/v1beta3", false)
disableV1beta3 := disableAllAPIs
disableV1beta3 = !s.getRuntimeConfigValue("api/v1beta3", !disableV1beta3)
// "api/v1={true|false} allows users to enable/disable v1 API. // "api/v1={true|false} allows users to enable/disable v1 API.
// This takes preference over api/all and api/legacy, if specified. // This takes preference over api/all and api/legacy, if specified.
@ -387,7 +384,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,
DisableV1Beta3: disableV1beta3, EnableV1Beta3: enableV1beta3,
DisableV1: disableV1, DisableV1: disableV1,
MasterServiceNamespace: s.MasterServiceNamespace, MasterServiceNamespace: s.MasterServiceNamespace,
ClusterName: s.ClusterName, ClusterName: s.ClusterName,

View File

@ -35,7 +35,7 @@ func init() {
} }
// The default list of supported api versions, in order of most preferred to the least. // The default list of supported api versions, in order of most preferred to the least.
defaultSupportedVersions := "v1,v1beta3" defaultSupportedVersions := "v1"
// Env var KUBE_API_VERSIONS is a comma separated list of API versions that should be registered in the scheme. // Env var KUBE_API_VERSIONS is a comma separated list of API versions that should be registered in the scheme.
// The versions should be in the order of most preferred to the least. // The versions should be in the order of most preferred to the least.
supportedVersions := os.Getenv("KUBE_API_VERSIONS") supportedVersions := os.Getenv("KUBE_API_VERSIONS")

View File

@ -95,8 +95,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 v1beta3 to be conditionally disabled // allow v1beta3 to be conditionally enabled
DisableV1Beta3 bool EnableV1Beta3 bool
// allow v1 to be conditionally disabled // allow v1 to be conditionally disabled
DisableV1 bool DisableV1 bool
// allow downstream consumers to disable the index route // allow downstream consumers to disable the index route
@ -337,7 +337,7 @@ func New(c *Config) *Master {
authenticator: c.Authenticator, authenticator: c.Authenticator,
authorizer: c.Authorizer, authorizer: c.Authorizer,
admissionControl: c.AdmissionControl, admissionControl: c.AdmissionControl,
v1beta3: !c.DisableV1Beta3, v1beta3: c.EnableV1Beta3,
v1: !c.DisableV1, v1: !c.DisableV1,
requestContextMapper: c.RequestContextMapper, requestContextMapper: c.RequestContextMapper,

View File

@ -393,6 +393,8 @@ func TestAuthModeAlwaysAllow(t *testing.T) {
EnableUISupport: false, EnableUISupport: false,
EnableIndex: true, EnableIndex: true,
APIPrefix: "/api", APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authorizer: apiserver.NewAlwaysAllowAuthorizer(), Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(), AdmissionControl: admit.NewAlwaysAdmit(),
}) })
@ -509,6 +511,8 @@ func TestAuthModeAlwaysDeny(t *testing.T) {
EnableUISupport: false, EnableUISupport: false,
EnableIndex: true, EnableIndex: true,
APIPrefix: "/api", APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authorizer: apiserver.NewAlwaysDenyAuthorizer(), Authorizer: apiserver.NewAlwaysDenyAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(), AdmissionControl: admit.NewAlwaysAdmit(),
}) })
@ -576,6 +580,8 @@ func TestAliceNotForbiddenOrUnauthorized(t *testing.T) {
EnableUISupport: false, EnableUISupport: false,
EnableIndex: true, EnableIndex: true,
APIPrefix: "/api", APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authenticator: getTestTokenAuth(), Authenticator: getTestTokenAuth(),
Authorizer: allowAliceAuthorizer{}, Authorizer: allowAliceAuthorizer{},
AdmissionControl: admit.NewAlwaysAdmit(), AdmissionControl: admit.NewAlwaysAdmit(),
@ -663,6 +669,8 @@ func TestBobIsForbidden(t *testing.T) {
EnableUISupport: false, EnableUISupport: false,
EnableIndex: true, EnableIndex: true,
APIPrefix: "/api", APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authenticator: getTestTokenAuth(), Authenticator: getTestTokenAuth(),
Authorizer: allowAliceAuthorizer{}, Authorizer: allowAliceAuthorizer{},
AdmissionControl: admit.NewAlwaysAdmit(), AdmissionControl: admit.NewAlwaysAdmit(),
@ -724,6 +732,8 @@ func TestUnknownUserIsUnauthorized(t *testing.T) {
EnableUISupport: false, EnableUISupport: false,
EnableIndex: true, EnableIndex: true,
APIPrefix: "/api", APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authenticator: getTestTokenAuth(), Authenticator: getTestTokenAuth(),
Authorizer: allowAliceAuthorizer{}, Authorizer: allowAliceAuthorizer{},
AdmissionControl: admit.NewAlwaysAdmit(), AdmissionControl: admit.NewAlwaysAdmit(),
@ -804,6 +814,8 @@ func TestNamespaceAuthorization(t *testing.T) {
EnableUISupport: false, EnableUISupport: false,
EnableIndex: true, EnableIndex: true,
APIPrefix: "/api", APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authenticator: getTestTokenAuth(), Authenticator: getTestTokenAuth(),
Authorizer: a, Authorizer: a,
AdmissionControl: admit.NewAlwaysAdmit(), AdmissionControl: admit.NewAlwaysAdmit(),
@ -919,6 +931,8 @@ func TestKindAuthorization(t *testing.T) {
EnableUISupport: false, EnableUISupport: false,
EnableIndex: true, EnableIndex: true,
APIPrefix: "/api", APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authenticator: getTestTokenAuth(), Authenticator: getTestTokenAuth(),
Authorizer: a, Authorizer: a,
AdmissionControl: admit.NewAlwaysAdmit(), AdmissionControl: admit.NewAlwaysAdmit(),
@ -1021,6 +1035,8 @@ func TestReadOnlyAuthorization(t *testing.T) {
EnableUISupport: false, EnableUISupport: false,
EnableIndex: true, EnableIndex: true,
APIPrefix: "/api", APIPrefix: "/api",
// enable v1beta3 if we are testing that api version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authenticator: getTestTokenAuth(), Authenticator: getTestTokenAuth(),
Authorizer: a, Authorizer: a,
AdmissionControl: admit.NewAlwaysAdmit(), AdmissionControl: admit.NewAlwaysAdmit(),

View File

@ -139,6 +139,8 @@ func startMasterOrDie(masterConfig *master.Config) (*master.Master, *httptest.Se
EnableProfiling: true, EnableProfiling: true,
EnableUISupport: false, EnableUISupport: false,
APIPrefix: "/api", APIPrefix: "/api",
// Enable v1bewta3 if we are testing that version
EnableV1Beta3: testapi.Version() == "v1beta3",
Authorizer: apiserver.NewAlwaysAllowAuthorizer(), Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(), AdmissionControl: admit.NewAlwaysAdmit(),
} }
@ -270,6 +272,8 @@ func RunAMaster(t *testing.T) (*master.Master, *httptest.Server) {
EnableProfiling: true, EnableProfiling: true,
EnableUISupport: false, EnableUISupport: false,
APIPrefix: "/api", APIPrefix: "/api",
// Enable v1bewta3 if we are testing that version
EnableV1Beta3: testapi.Version() == "v1beta3",
Authorizer: apiserver.NewAlwaysAllowAuthorizer(), Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(), AdmissionControl: admit.NewAlwaysAdmit(),
}) })

View File

@ -73,6 +73,8 @@ func TestUnschedulableNodes(t *testing.T) {
EnableUISupport: false, EnableUISupport: false,
EnableIndex: true, EnableIndex: true,
APIPrefix: "/api", APIPrefix: "/api",
// Enable v1beta3 if we are testing that version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authorizer: apiserver.NewAlwaysAllowAuthorizer(), Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(), AdmissionControl: admit.NewAlwaysAdmit(),
}) })

View File

@ -66,6 +66,8 @@ func TestSecrets(t *testing.T) {
EnableUISupport: false, EnableUISupport: false,
EnableIndex: true, EnableIndex: true,
APIPrefix: "/api", APIPrefix: "/api",
// Enable v1beta3 if we are testing that version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authorizer: apiserver.NewAlwaysAllowAuthorizer(), Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(), AdmissionControl: admit.NewAlwaysAdmit(),
}) })

View File

@ -416,6 +416,8 @@ func startServiceAccountTestServer(t *testing.T) (*client.Client, client.Config,
EnableUISupport: false, EnableUISupport: false,
EnableIndex: true, EnableIndex: true,
APIPrefix: "/api", APIPrefix: "/api",
// Enable v1beta3 if we are testing that version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authenticator: authenticator, Authenticator: authenticator,
Authorizer: authorizer, Authorizer: authorizer,
AdmissionControl: serviceAccountAdmission, AdmissionControl: serviceAccountAdmission,

View File

@ -80,6 +80,8 @@ func runAMaster(t *testing.T) (*master.Master, *httptest.Server) {
EnableProfiling: true, EnableProfiling: true,
EnableUISupport: false, EnableUISupport: false,
APIPrefix: "/api", APIPrefix: "/api",
// Enable v1beta3 if we are testing that version.
EnableV1Beta3: testapi.Version() == "v1beta3",
Authorizer: apiserver.NewAlwaysAllowAuthorizer(), Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(), AdmissionControl: admit.NewAlwaysAdmit(),
}) })