diff --git a/cmd/kube-apiserver/app/server.go b/cmd/kube-apiserver/app/server.go index 62bc5c24f88..027dbfd7acc 100644 --- a/cmd/kube-apiserver/app/server.go +++ b/cmd/kube-apiserver/app/server.go @@ -184,13 +184,6 @@ func CreateServerChain(completedOptions completedServerRunOptions, stopCh <-chan return nil, err } - // otherwise go down the normal path of standing the aggregator up in front of the API server - // this wires up openapi - kubeAPIServer.GenericAPIServer.PrepareRun() - - // This will wire up openapi for extension api server - apiExtensionsServer.GenericAPIServer.PrepareRun() - // aggregator comes last in the chain aggregatorConfig, err := createAggregatorConfig(*kubeAPIServerConfig.GenericConfig, completedOptions.ServerRunOptions, kubeAPIServerConfig.ExtraConfig.VersionedInformers, serviceResolver, proxyTransport, pluginInitializer) if err != nil { diff --git a/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go b/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go index 5ca0f009a8f..1e75774f45d 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go +++ b/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go @@ -205,6 +205,9 @@ type DelegationTarget interface { // NextDelegate returns the next delegationTarget in the chain of delegations NextDelegate() DelegationTarget + + // PrepareRun does post API installation setup steps. It calls recursively the same function of the delegates. + PrepareRun() preparedGenericAPIServer } func (s *GenericAPIServer) UnprotectedHandler() http.Handler { @@ -253,14 +256,19 @@ func (s emptyDelegate) ListedPaths() []string { func (s emptyDelegate) NextDelegate() DelegationTarget { return nil } +func (s emptyDelegate) PrepareRun() preparedGenericAPIServer { + return preparedGenericAPIServer{nil} +} // preparedGenericAPIServer is a private wrapper that enforces a call of PrepareRun() before Run can be invoked. type preparedGenericAPIServer struct { *GenericAPIServer } -// PrepareRun does post API installation setup steps. +// PrepareRun does post API installation setup steps. It calls recursively the same function of the delegates. func (s *GenericAPIServer) PrepareRun() preparedGenericAPIServer { + s.delegationTarget.PrepareRun() + if s.openAPIConfig != nil { s.OpenAPIVersionedService, s.StaticOpenAPISpec = routes.OpenAPI{ Config: s.openAPIConfig,