Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make master index optional when master is used in other contexts #3997

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 19 additions & 12 deletions pkg/master/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,21 @@ import (

// Config is a structure used to configure a Master.
type Config struct {
Client *client.Client
Cloud cloudprovider.Interface
EtcdHelper tools.EtcdHelper
EventTTL time.Duration
MinionRegexp string
KubeletClient client.KubeletClient
PortalNet *net.IPNet
EnableLogsSupport bool
EnableUISupport bool
EnableSwaggerSupport bool
EnableV1Beta3 bool
Client *client.Client
Cloud cloudprovider.Interface
EtcdHelper tools.EtcdHelper
EventTTL time.Duration
MinionRegexp string
KubeletClient client.KubeletClient
PortalNet *net.IPNet
EnableLogsSupport bool
EnableUISupport bool
// allow downstream consumers to disable swagger
EnableSwaggerSupport bool
// allow v1beta3 to be conditionally enabled
EnableV1Beta3 bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did gofmt do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, comments reset the margin on the right items.

----- Original Message -----

  • EnableUISupport bool
  • EnableSwaggerSupport bool
  • EnableV1Beta3 bool
  • Client *client.Client
  • Cloud cloudprovider.Interface
  • EtcdHelper tools.EtcdHelper
  • EventTTL time.Duration
  • MinionRegexp string
  • KubeletClient client.KubeletClient
  • PortalNet *net.IPNet
  • EnableLogsSupport bool
  • EnableUISupport bool
  • // allow downstream consumers to disable swagger
  • EnableSwaggerSupport bool
  • // allow v1beta3 to be conditionally enabled
  • EnableV1Beta3 bool

Did gofmt do this?


Reply to this email directly or view it on GitHub:
https://github.com/GoogleCloudPlatform/kubernetes/pull/3997/files#r23884082

// allow downstream consumers to disable the index route
EnableIndex bool
APIPrefix string
CorsAllowedOriginList util.StringList
Authenticator authenticator.Request
Expand Down Expand Up @@ -384,7 +388,10 @@ func (m *Master) init(c *Config) {

// Register root handler.
// We do not register this using restful Webservice since we do not want to surface this in api docs.
m.mux.HandleFunc("/", apiserver.IndexHandler(m.handlerContainer, m.muxHelper))
// Allow master to be embedded in contexts which already have something registered at the root
if c.EnableIndex {
m.mux.HandleFunc("/", apiserver.IndexHandler(m.handlerContainer, m.muxHelper))
}

// TODO: use go-restful
apiserver.InstallValidator(m.muxHelper, func() map[string]apiserver.Server { return m.getServersToValidate(c) })
Expand Down
1 change: 1 addition & 0 deletions pkg/master/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ func (s *APIServer) Run(_ []string) error {
EnableLogsSupport: s.EnableLogsSupport,
EnableUISupport: true,
EnableSwaggerSupport: true,
EnableIndex: true,
APIPrefix: s.APIPrefix,
CorsAllowedOriginList: s.CorsAllowedOriginList,
ReadOnlyPort: s.ReadOnlyPort,
Expand Down
1 change: 1 addition & 0 deletions pkg/standalone/standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func RunApiServer(cl *client.Client, etcdClient tools.EtcdClient, addr string, p
},
EnableLogsSupport: false,
EnableSwaggerSupport: true,
EnableIndex: true,
APIPrefix: "/api",
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),

Expand Down
8 changes: 8 additions & 0 deletions test/integration/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ func TestAuthModeAlwaysAllow(t *testing.T) {
KubeletClient: client.FakeKubeletClient{},
EnableLogsSupport: false,
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
Expand Down Expand Up @@ -353,6 +354,7 @@ func TestAuthModeAlwaysDeny(t *testing.T) {
KubeletClient: client.FakeKubeletClient{},
EnableLogsSupport: false,
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
Authorizer: apiserver.NewAlwaysDenyAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
Expand Down Expand Up @@ -418,6 +420,7 @@ func TestAliceNotForbiddenOrUnauthorized(t *testing.T) {
KubeletClient: client.FakeKubeletClient{},
EnableLogsSupport: false,
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
Authenticator: getTestTokenAuth(),
Authorizer: allowAliceAuthorizer{},
Expand Down Expand Up @@ -478,6 +481,7 @@ func TestBobIsForbidden(t *testing.T) {
KubeletClient: client.FakeKubeletClient{},
EnableLogsSupport: false,
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
Authenticator: getTestTokenAuth(),
Authorizer: allowAliceAuthorizer{},
Expand Down Expand Up @@ -538,6 +542,7 @@ func TestUnknownUserIsUnauthorized(t *testing.T) {
KubeletClient: client.FakeKubeletClient{},
EnableLogsSupport: false,
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
Authenticator: getTestTokenAuth(),
Authorizer: allowAliceAuthorizer{},
Expand Down Expand Up @@ -617,6 +622,7 @@ func TestNamespaceAuthorization(t *testing.T) {
KubeletClient: client.FakeKubeletClient{},
EnableLogsSupport: false,
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
Authenticator: getTestTokenAuth(),
Authorizer: a,
Expand Down Expand Up @@ -701,6 +707,7 @@ func TestKindAuthorization(t *testing.T) {
KubeletClient: client.FakeKubeletClient{},
EnableLogsSupport: false,
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
Authenticator: getTestTokenAuth(),
Authorizer: a,
Expand Down Expand Up @@ -779,6 +786,7 @@ func TestReadOnlyAuthorization(t *testing.T) {
KubeletClient: client.FakeKubeletClient{},
EnableLogsSupport: false,
EnableUISupport: false,
EnableIndex: true,
APIPrefix: "/api",
Authenticator: getTestTokenAuth(),
Authorizer: a,
Expand Down