Skip to content

Commit

Permalink
Merge pull request #10892 from pmorie/attach-detach-sa
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Sep 14, 2016
2 parents ea6ca28 + dd1ce84 commit e9081ae
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 0 deletions.
52 changes: 52 additions & 0 deletions pkg/cmd/server/bootstrappolicy/infra_sa_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const (
InfraPersistentVolumeBinderControllerServiceAccountName = "pv-binder-controller"
PersistentVolumeBinderControllerRoleName = "system:pv-binder-controller"

InfraPersistentVolumeAttachDetachControllerServiceAccountName = "pv-attach-detach-controller"
PersistentVolumeAttachDetachControllerRoleName = "system:pv-attach-detach-controller"

InfraPersistentVolumeRecyclerControllerServiceAccountName = "pv-recycler-controller"
PersistentVolumeRecyclerControllerRoleName = "system:pv-recycler-controller"

Expand Down Expand Up @@ -464,6 +467,55 @@ func init() {
panic(err)
}

err = InfraSAs.addServiceAccount(
InfraPersistentVolumeAttachDetachControllerServiceAccountName,
authorizationapi.ClusterRole{
ObjectMeta: kapi.ObjectMeta{
Name: PersistentVolumeAttachDetachControllerRoleName,
},
Rules: []authorizationapi.PolicyRule{
// shared informer on PVs
{
Verbs: sets.NewString("list", "watch"),
Resources: sets.NewString("persistentvolumes"),
},
// shared informer on PVCs
{
Verbs: sets.NewString("list", "watch"),
Resources: sets.NewString("persistentvolumeclaims"),
},
// shared informer on nodes
{
Verbs: sets.NewString("list", "watch"),
Resources: sets.NewString("nodes"),
},
// operationexecutor uses get with nodes
{
Verbs: sets.NewString("get"),
Resources: sets.NewString("nodes"),
},
// strategic patch on nodes/status
{
Verbs: sets.NewString("patch", "update"),
Resources: sets.NewString("nodes/status"),
},
// shared informer on pods
{
Verbs: sets.NewString("list", "watch"),
Resources: sets.NewString("pods"),
},
// normal event usage
{
Verbs: sets.NewString("create", "update", "patch"),
Resources: sets.NewString("events"),
},
},
},
)
if err != nil {
panic(err)
}

err = InfraSAs.addServiceAccount(
InfraPersistentVolumeBinderControllerServiceAccountName,
authorizationapi.ClusterRole{
Expand Down
3 changes: 3 additions & 0 deletions pkg/cmd/server/kubernetes/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ func (c *MasterConfig) RunPersistentVolumeController(client *client.Client, name
s.VolumeConfiguration.EnableDynamicProvisioning,
)
volumeController.Run()
}

func (c *MasterConfig) RunPersistentVolumeAttachDetachController(client *client.Client) {
s := c.ControllerManager
attachDetachController, err :=
attachdetachcontroller.NewAttachDetachController(
clientadapter.FromUnversionedClient(client),
Expand Down
6 changes: 6 additions & 0 deletions pkg/cmd/server/start/start_master.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,11 @@ func startControllers(oc *origin.MasterConfig, kc *kubernetes.MasterConfig) erro
glog.Fatalf("Could not get client for persistent volume binder controller: %v", err)
}

_, _, attachDetachControllerClient, err := oc.GetServiceAccountClients(bootstrappolicy.InfraPersistentVolumeAttachDetachControllerServiceAccountName)
if err != nil {
glog.Fatalf("Could not get client for attach detach controller: %v", err)
}

_, _, daemonSetClient, err := oc.GetServiceAccountClients(bootstrappolicy.InfraDaemonSetControllerServiceAccountName)
if err != nil {
glog.Fatalf("Could not get client for daemonset controller: %v", err)
Expand Down Expand Up @@ -641,6 +646,7 @@ func startControllers(oc *origin.MasterConfig, kc *kubernetes.MasterConfig) erro
kc.RunEndpointController(endpointControllerClient)
kc.RunNamespaceController(namespaceControllerClientSet, namespaceControllerClientPool)
kc.RunPersistentVolumeController(binderClient, oc.Options.PolicyConfig.OpenShiftInfrastructureNamespace, oc.ImageFor("recycler"), bootstrappolicy.InfraPersistentVolumeRecyclerControllerServiceAccountName)
kc.RunPersistentVolumeAttachDetachController(attachDetachControllerClient)
kc.RunGCController(gcClient)

kc.RunServiceLoadBalancerController(serviceLoadBalancerClient)
Expand Down
62 changes: 62 additions & 0 deletions test/testdata/bootstrappolicy/bootstrap_cluster_roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2742,6 +2742,68 @@ items:
- create
- patch
- update
- apiVersion: v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: system:pv-attach-detach-controller
rules:
- apiGroups:
- ""
attributeRestrictions: null
resources:
- persistentvolumes
verbs:
- list
- watch
- apiGroups:
- ""
attributeRestrictions: null
resources:
- persistentvolumeclaims
verbs:
- list
- watch
- apiGroups:
- ""
attributeRestrictions: null
resources:
- nodes
verbs:
- list
- watch
- apiGroups:
- ""
attributeRestrictions: null
resources:
- nodes
verbs:
- get
- apiGroups:
- ""
attributeRestrictions: null
resources:
- nodes/status
verbs:
- patch
- update
- apiGroups:
- ""
attributeRestrictions: null
resources:
- pods
verbs:
- list
- watch
- apiGroups:
- ""
attributeRestrictions: null
resources:
- events
verbs:
- create
- patch
- update
- apiVersion: v1
kind: ClusterRole
metadata:
Expand Down

0 comments on commit e9081ae

Please sign in to comment.