-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Once we transition to k8s 1.11 and merge the subresources PR #786 we should be able to utilize RBAC to limit which system components can update different resources and subresources (status & scale).
See slack for some discussion https://knative.slack.com/archives/C93E33SN8/p1528725270000107
Background Info
Under Authentication, authorization, and auditing
CRDs always use the same authentication, authorization, and audit logging as the built-in resources of your API Server.
If you use RBAC for authorization, most RBAC roles will not grant access to the new resources (except the cluster-admin role or any role created with wildcard rules). You’ll need to explicitly grant access to the new resources. CRDs and Aggregated APIs often come bundled with new role definitions for the types they add.
Our controllers use the cluster-admin role specified here:
serving/config/201-clusterrolebinding.yaml
Lines 15 to 26 in e1b3aae
| apiVersion: rbac.authorization.k8s.io/v1beta1 | |
| kind: ClusterRoleBinding | |
| metadata: | |
| name: knative-serving-controller-admin | |
| subjects: | |
| - kind: ServiceAccount | |
| name: controller | |
| namespace: knative-serving-system | |
| roleRef: | |
| kind: ClusterRole | |
| name: cluster-admin | |
| apiGroup: rbac.authorization.k8s.io |
We can make these permissions more fine grained. In Referring to Resources
Most resources are represented by a string representation of their name, such as “pods”, just as it appears in the URL for the relevant API endpoint. However, some Kubernetes APIs involve a “subresource”, such as the logs for a pod
...
To represent this in an RBAC role, use a slash to delimit the resource and subresource.kind: Role apiVersion: rbac.authorization.k8s.io/v1 metadata: namespace: default name: pod-and-pod-logs-reader rules: - apiGroups: [""] resources: ["pods", "pods/log"] verbs: ["get", "list"]
Related:
Clusterrole binding (#1095)
Best practices for updating [CRD] status (#1107)
Best practices for updating a CRD's metadata (#1127)
Best practices for updating a CRD's spec (#1128)