Skip to content

Commit 81635a2

Browse files
Remove an oc dependency on the RBAC server
Move the dependency into the master startup flow.
1 parent cab698e commit 81635a2

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

pkg/cmd/server/bootstrappolicy/all.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
package bootstrappolicy
22

33
import (
4-
rbacrest "k8s.io/kubernetes/pkg/registry/rbac/rest"
4+
"k8s.io/kubernetes/pkg/apis/rbac"
55
)
66

7-
func Policy() *rbacrest.PolicyData {
8-
return &rbacrest.PolicyData{
7+
type PolicyData struct {
8+
ClusterRoles []rbac.ClusterRole
9+
ClusterRoleBindings []rbac.ClusterRoleBinding
10+
Roles map[string][]rbac.Role
11+
RoleBindings map[string][]rbac.RoleBinding
12+
// ClusterRolesToAggregate maps from previous clusterrole name to the new clusterrole name
13+
ClusterRolesToAggregate map[string]string
14+
}
15+
16+
func Policy() *PolicyData {
17+
return &PolicyData{
918
ClusterRoles: GetBootstrapClusterRoles(),
1019
ClusterRoleBindings: GetBootstrapClusterRoleBindings(),
1120
Roles: GetBootstrapNamespaceRoles(),

pkg/cmd/server/origin/master.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
aggregatorapiserver "k8s.io/kube-aggregator/pkg/apiserver"
1717
kubeapiserver "k8s.io/kubernetes/pkg/master"
1818
kcorestorage "k8s.io/kubernetes/pkg/registry/core/rest"
19+
rbacrest "k8s.io/kubernetes/pkg/registry/rbac/rest"
1920

2021
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
2122
kubernetes "github.com/openshift/origin/pkg/cmd/server/kubernetes/master"
@@ -265,7 +266,7 @@ func (c *MasterConfig) Run(stopCh <-chan struct{}) error {
265266
}
266267

267268
// add post-start hooks
268-
aggregatedAPIServer.GenericAPIServer.AddPostStartHookOrDie("authorization.openshift.io-bootstrapclusterroles", bootstrappolicy.Policy().EnsureRBACPolicy())
269+
aggregatedAPIServer.GenericAPIServer.AddPostStartHookOrDie("authorization.openshift.io-bootstrapclusterroles", bootstrapData(bootstrappolicy.Policy()).EnsureRBACPolicy())
269270
aggregatedAPIServer.GenericAPIServer.AddPostStartHookOrDie("authorization.openshift.io-ensureopenshift-infra", ensureOpenShiftInfraNamespace)
270271
aggregatedAPIServer.GenericAPIServer.AddPostStartHookOrDie("quota.openshift.io-clusterquotamapping", c.startClusterQuotaMapping)
271272
for name, fn := range c.additionalPostStartHooks {
@@ -323,7 +324,7 @@ func (c *MasterConfig) RunKubeAPIServer(stopCh <-chan struct{}) error {
323324
}
324325
}
325326

326-
aggregatedAPIServer.GenericAPIServer.AddPostStartHookOrDie("authorization.openshift.io-bootstrapclusterroles", bootstrappolicy.Policy().EnsureRBACPolicy())
327+
aggregatedAPIServer.GenericAPIServer.AddPostStartHookOrDie("authorization.openshift.io-bootstrapclusterroles", bootstrapData(bootstrappolicy.Policy()).EnsureRBACPolicy())
327328
aggregatedAPIServer.GenericAPIServer.AddPostStartHookOrDie("authorization.openshift.io-ensureopenshift-infra", ensureOpenShiftInfraNamespace)
328329
aggregatedAPIServer.GenericAPIServer.AddPostStartHookOrDie("quota.openshift.io-clusterquotamapping", c.startClusterQuotaMapping)
329330
// add post-start hooks
@@ -471,3 +472,15 @@ func (c *MasterConfig) startClusterQuotaMapping(context apiserver.PostStartHookC
471472
go c.ClusterQuotaMappingController.Run(5, context.StopCh)
472473
return nil
473474
}
475+
476+
// bootstrapData casts our policy data to the rbacrest helper that can
477+
// materialize the policy.
478+
func bootstrapData(data *bootstrappolicy.PolicyData) *rbacrest.PolicyData {
479+
return &rbacrest.PolicyData{
480+
ClusterRoles: data.ClusterRoles,
481+
ClusterRoleBindings: data.ClusterRoleBindings,
482+
Roles: data.Roles,
483+
RoleBindings: data.RoleBindings,
484+
ClusterRolesToAggregate: data.ClusterRolesToAggregate,
485+
}
486+
}

0 commit comments

Comments
 (0)