-
Notifications
You must be signed in to change notification settings - Fork 592
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
Explicit cluster roles for controller/webhook, not cluster-admin #872
Conversation
config/200-webhook-clusterrole.yaml
Outdated
resources: ["channels", "clusterchannelprovisioners", "subscriptions"] | ||
verbs: ["get", "list", "create", "watch"] | ||
- apiGroups: ["eventing.knative.dev"] | ||
resources: ["channels/status", "clusterchannelprovisioners/status", "subscriptions/status"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My preference would be to put these into the previous list, so that after each foo
, we then have foo/status
. I think that will make it easier to see when one has been forgotten.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for doing this @vaikas-google! It's embarrassing that we've had cluster-admin for so long.
How did you come up with the list of permissions for the controller SA?
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] | ||
- apiGroups: ["apiextensions.k8s.io"] | ||
resources: ["customresourcedefinitions"] | ||
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the controller really need write permissions on CRDs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these permissions apply to CRDs or all the custom resources whose type is a CRD? If the former, why do we need any permissions on CRDs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left over cruft, removed.
verbs: ["get", "list", "watch"] | ||
# For manipulating certs into secrets | ||
- apiGroups: [""] | ||
resources: ["secrets"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is a candidate for a (namespaced) Role
so the webhook doesn't have access to all secrets everywhere. Seems like maybe configmaps and deployments permissions could also be namespaced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok to make this into a separate issue and tackle that in a followup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to a followup issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more comments, but thanks for doing this.
If you want the further refinements to go into another PR, feel free to open an issue; this is already a definite improvement.
/hold
/lgtm
name: knative-eventing-controller | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["namespaces", "secrets", "configmaps", "services", "events", "serviceaccounts"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need list/delete/watch on events? (Or create/update/patch for namespaces, secrets or serviceaccounts?)
May not be worth pulling out separately.
resources: ["routes", "services"] | ||
verbs: ["get", "list", "watch"] | ||
- apiGroups: ["serving.knative.dev"] | ||
resources: ["routes/status", "services/status"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We merge the "foo" and "foo/status" on line 34. Do we want to do the same here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure thing, done.
- apiGroups: ["eventing.knative.dev"] | ||
resources: ["brokers", "brokers/status", "channels", "channels/status", "clusterchannelprovisioners", "clusterchannelprovisioners/status", "subscriptions", "subscriptions/status", "triggers", "triggers/status",] | ||
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] | ||
- apiGroups: ["apps"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's strange to have this apiGroup
down here but virtualservices
on line 30.
Maybe put in a comment # Resources we create as part of our side effects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad :) moved...
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] | ||
- apiGroups: ["rbac.authorization.k8s.io"] | ||
resources: ["rolebindings"] | ||
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need these permissions on rolebindings
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are needed for triggers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah -- this is actually needed for the namespace Broker auto-provisioner. https://github.com/knative/eventing/blob/master/pkg/reconciler/v1alpha1/namespace/namespace.go#L264
I wonder if we want to extract the Broker auto-provisioner at some point in the future.
verbs: ["get", "list", "watch"] | ||
# For manipulating certs into secrets | ||
- apiGroups: [""] | ||
resources: ["secrets"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to a followup issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] | ||
- apiGroups: ["rbac.authorization.k8s.io"] | ||
resources: ["rolebindings"] | ||
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah -- this is actually needed for the namespace Broker auto-provisioner. https://github.com/knative/eventing/blob/master/pkg/reconciler/v1alpha1/namespace/namespace.go#L264
I wonder if we want to extract the Broker auto-provisioner at some point in the future.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: evankanderson, vaikas-google The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
As long as this is titled "WIP", it won't merge. (FYI) |
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: eventing-webhook-admin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to eventing-webook
, or something similar as this is no longer granting admin.
Do a similar rename to eventing-controller-admin
. This will mean that it won't update the existing RBAC on upgrade, if you consider that important.
# Our own resources and statuses we care about | ||
- apiGroups: ["eventing.knative.dev"] | ||
resources: ["brokers", "brokers/status", "channels", "channels/status", "clusterchannelprovisioners", "clusterchannelprovisioners/status", "subscriptions", "subscriptions/status", "triggers", "triggers/status",] | ||
verbs: ["get", "list", "create", "watch"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use create in the webhook?
/lgtm Holding in case you want to change in response to my comments. If not, feel free to cancel the hold yourself. |
/lgtm |
I've created: |
Fixes #749
Proposed Changes
Release Note