Skip to content

Add service account for attach-detach controller #10892

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

Merged
merged 1 commit into from
Sep 14, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"),
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need get on any of the list/watch resources?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we need it on nodes, which is accounted for.

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