Skip to content

Aggregated ClusterRole for Addressables #916

@Harwayne

Description

@Harwayne

Expected Behavior

I should be able to create a ServiceAccount and give it RBAC permissions to resolve all known Addressables. If a new Addressable Kind is created, my ServiceAccount should get permission to resolve it as well, without needing any work specific to this ServiceAccount.

Actual Behavior

Today all the ServiceAccounts seem to get their own custom ClusterRoles that include all known Addressables at the time. Creating a new Addressable causes all of those ClusterRoles to be updated (see knative/eventing-contrib#252).

Proposal

We create a single aggregated ClusterRole. Then whenever a new Addressable is created, it is the responsibility of that CRD's author to create a ClusterRole that will aggregate the new permissions into the single aggregated ClusterRole.

E.g.

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: addressable-resolver
aggregationRule:
  clusterRoleSelectors:
  - matchLabels:
      eventing.knative.dev/addressable: "true"
rules: [] # Rules are automatically filled in by the controller manager.

Then to make Broker resolve correctly, the creator of the Broker CRD also creates the following:

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: broker-addressable-resolver
  labels:
      eventing.knative.dev/addressable: "true"
# Do not use this role directly. These rules will be added to the "addressable-resolver" role.
rules:
- apiGroups:
  - eventing.knative.dev/v1alpha1
  resources:
  - brokers
  - brokers/status
  verbs:
  - get
  - list
  - watch

Then, as a user creating a ServiceAccount that needs to resolve Addressables, I give the following ClusterRoleBinding/RoleBinding:

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: foo-addressable-resolver
subjects:
- kind: serviceAccount
  name: foo
roleRef:
  kind: ClusterRole
  name: addressable-resolver
  apiGroup: rbac.authorization.k8s.io

So when someone adds another Addressable CRD (e.g. Channel), they also add the ClusterRole that will get aggregated into addressable-resolver and the ServiceAccount foo automatically gets that permission without any further work.

Metadata

Metadata

Assignees

Labels

help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/good-first-issueDenotes an issue ready for a new contributor.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions