@@ -14,29 +14,29 @@ import (
1414 aggregatorapiserver "k8s.io/kube-aggregator/pkg/apiserver"
1515 kubeapiserver "k8s.io/kubernetes/pkg/master"
1616 kcorestorage "k8s.io/kubernetes/pkg/registry/core/rest"
17- rbacrest "k8s.io/kubernetes/pkg/registry/rbac/rest"
1817
1918 "github.com/openshift/origin/pkg/cmd/openshift-apiserver/openshiftapiserver"
2019 "github.com/openshift/origin/pkg/cmd/openshift-apiserver/openshiftapiserver/configprocessing"
2120 "github.com/openshift/origin/pkg/cmd/openshift-kube-apiserver/openshiftkubeapiserver"
22- "github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
2321 kubernetes "github.com/openshift/origin/pkg/cmd/server/kubernetes/master"
2422 cmdutil "github.com/openshift/origin/pkg/cmd/util"
2523 sccstorage "github.com/openshift/origin/pkg/security/apiserver/registry/securitycontextconstraints/etcd"
26- "k8s.io/apimachinery/pkg/util/wait"
2724 kapiserveroptions "k8s.io/kubernetes/cmd/kube-apiserver/app/options"
2825)
2926
3027func (c * MasterConfig ) newOpenshiftAPIConfig (kubeAPIServerConfig apiserver.Config ) (* openshiftapiserver.OpenshiftAPIConfig , error ) {
28+ var err error
3129 // sccStorage must use the upstream RESTOptionsGetter to be in the correct location
3230 // this probably creates a duplicate cache, but there are not very many SCCs, so live with it to avoid further linkage
3331 sccStorage := sccstorage .NewREST (kubeAPIServerConfig .RESTOptionsGetter )
3432
3533 // make a shallow copy to let us twiddle a few things
3634 // most of the config actually remains the same. We only need to mess with a couple items
3735 genericConfig := kubeAPIServerConfig
38- // TODO try to stop special casing these. We should all agree on them.
39- genericConfig .RESTOptionsGetter = c .RESTOptionsGetter
36+ genericConfig .RESTOptionsGetter , err = openshiftapiserver .NewRESTOptionsGetter (c .Options )
37+ if err != nil {
38+ return nil , err
39+ }
4040
4141 var caData []byte
4242 if len (c .Options .ImagePolicyConfig .AdditionalTrustedCA ) != 0 {
@@ -237,90 +237,3 @@ func (c *MasterConfig) Run(stopCh <-chan struct{}) error {
237237 // Attempt to verify the server came up for 20 seconds (100 tries * 100ms, 100ms timeout per try)
238238 return cmdutil .WaitForSuccessfulDial (true , c .Options .ServingInfo .BindNetwork , c .Options .ServingInfo .BindAddress , 100 * time .Millisecond , 100 * time .Millisecond , 100 )
239239}
240-
241- func (c * MasterConfig ) RunKubeAPIServer (stopCh <- chan struct {}) error {
242- var err error
243- var apiExtensionsInformers apiextensionsinformers.SharedInformerFactory
244- var delegateAPIServer apiserver.DelegationTarget
245- var extraPostStartHooks map [string ]apiserver.PostStartHookFunc
246-
247- c .kubeAPIServerConfig .GenericConfig .BuildHandlerChainFunc , extraPostStartHooks , err = openshiftkubeapiserver .BuildHandlerChain (c .kubeAPIServerConfig .GenericConfig , c .ClientGoKubeInformers , & c .Options )
248- if err != nil {
249- return err
250- }
251-
252- kubeAPIServerOptions , err := kubernetes .BuildKubeAPIserverOptions (c .Options )
253- if err != nil {
254- return err
255- }
256-
257- delegateAPIServer = apiserver .NewEmptyDelegate ()
258- delegateAPIServer , apiExtensionsInformers , err = c .withAPIExtensions (delegateAPIServer , kubeAPIServerOptions , * c .kubeAPIServerConfig .GenericConfig )
259- if err != nil {
260- return err
261- }
262- delegateAPIServer , err = c .withNonAPIRoutes (delegateAPIServer , * c .kubeAPIServerConfig .GenericConfig )
263- if err != nil {
264- return err
265- }
266- delegateAPIServer , err = c .withKubeAPI (delegateAPIServer , * c .kubeAPIServerConfig )
267- if err != nil {
268- return err
269- }
270- aggregatedAPIServer , err := c .withAggregator (delegateAPIServer , kubeAPIServerOptions , * c .kubeAPIServerConfig .GenericConfig , apiExtensionsInformers )
271- if err != nil {
272- return err
273- }
274-
275- // Start the audit backend before any request comes in. This means we cannot turn it into a
276- // post start hook because without calling Backend.Run the Backend.ProcessEvents call might block.
277- if c .AuditBackend != nil {
278- if err := c .AuditBackend .Run (stopCh ); err != nil {
279- return fmt .Errorf ("failed to run the audit backend: %v" , err )
280- }
281- }
282-
283- aggregatedAPIServer .GenericAPIServer .AddPostStartHookOrDie ("authorization.openshift.io-bootstrapclusterroles" , bootstrapData (bootstrappolicy .Policy ()).EnsureRBACPolicy ())
284- aggregatedAPIServer .GenericAPIServer .AddPostStartHookOrDie ("openshift.io-startinformers" , func (context apiserver.PostStartHookContext ) error {
285- c .InformerStart (context .StopCh )
286- return nil
287- })
288- aggregatedAPIServer .GenericAPIServer .AddPostStartHookOrDie ("openshift.io-restmapperupdater" , func (context apiserver.PostStartHookContext ) error {
289- c .RESTMapper .Reset ()
290- go func () {
291- wait .Until (func () {
292- c .RESTMapper .Reset ()
293- }, 10 * time .Second , context .StopCh )
294- }()
295- return nil
296- })
297- aggregatedAPIServer .GenericAPIServer .AddPostStartHookOrDie ("quota.openshift.io-clusterquotamapping" , func (context apiserver.PostStartHookContext ) error {
298- go c .ClusterQuotaMappingController .Run (5 , context .StopCh )
299- return nil
300- })
301-
302- // add post-start hooks
303- for name , fn := range c .additionalPostStartHooks {
304- aggregatedAPIServer .GenericAPIServer .AddPostStartHookOrDie (name , fn )
305- }
306- for name , fn := range extraPostStartHooks {
307- aggregatedAPIServer .GenericAPIServer .AddPostStartHookOrDie (name , fn )
308- }
309-
310- go aggregatedAPIServer .GenericAPIServer .PrepareRun ().Run (stopCh )
311-
312- // Attempt to verify the server came up for 20 seconds (100 tries * 100ms, 100ms timeout per try)
313- return cmdutil .WaitForSuccessfulDial (true , c .Options .ServingInfo .BindNetwork , c .Options .ServingInfo .BindAddress , 100 * time .Millisecond , 100 * time .Millisecond , 100 )
314- }
315-
316- // bootstrapData casts our policy data to the rbacrest helper that can
317- // materialize the policy.
318- func bootstrapData (data * bootstrappolicy.PolicyData ) * rbacrest.PolicyData {
319- return & rbacrest.PolicyData {
320- ClusterRoles : data .ClusterRoles ,
321- ClusterRoleBindings : data .ClusterRoleBindings ,
322- Roles : data .Roles ,
323- RoleBindings : data .RoleBindings ,
324- ClusterRolesToAggregate : data .ClusterRolesToAggregate ,
325- }
326- }
0 commit comments