Skip to content
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

Add permissions for serving APIs to k8s's default view and edit role #5683

Merged
merged 1 commit into from
Sep 29, 2019

Conversation

nak3
Copy link
Contributor

@nak3 nak3 commented Sep 26, 2019

Proposed Changes

This patch adds permissions for knative serving API to edit and view role.

The edit and view roles are k8s's default user-facing role.
So, Users should be able to assume that they can access or edit serving resources by
using these roles.

/lint

Release Note

`200-clusterrole-namespaced.yaml` added clusterroles to access or edit serving resources by using view and edit clusterrole.

This patch adds some permissions for knative serving API to edit and view role

The `edit` and `view` roles are k8s's default [user-facing
role](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles).
So, Users should be able to assume that they can access or edit serving resources by
using these roles.
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Sep 26, 2019
@knative-prow-robot knative-prow-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 26, 2019
Copy link
Contributor

@markusthoemmes markusthoemmes left a comment

Choose a reason for hiding this comment

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

Neat!

/lgtm
/approve
/assign @mattmoor

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 26, 2019
@mgencur
Copy link
Contributor

mgencur commented Sep 26, 2019

I suppose there will be the same problem with Knative Eventing.

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: markusthoemmes, mattmoor, nak3

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 29, 2019
@knative-test-reporter-robot

The following jobs failed:

Test name Triggers Retries
pull-knative-serving-unit-tests pull-knative-serving-unit-tests
pull-knative-serving-unit-tests
pull-knative-serving-unit-tests
pull-knative-serving-unit-tests
3/3

Job pull-knative-serving-unit-tests expended all 3 retries without success.

@nak3
Copy link
Contributor Author

nak3 commented Sep 29, 2019

/test pull-knative-serving-unit-tests

1 similar comment
@nak3
Copy link
Contributor Author

nak3 commented Sep 29, 2019

/test pull-knative-serving-unit-tests

@knative-prow-robot knative-prow-robot merged commit df65e57 into knative:master Sep 29, 2019
@nak3 nak3 deleted the add-edit-view branch September 29, 2019 23:39
rules:
- apiGroups: ["serving.knative.dev", "networking.internal.knative.dev", "autoscaling.internal.knative.dev"]
resources: ["*"]
verbs: ["create", "update", "patch", "delete"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we need to either include the read APIs here or have the next CR also aggregate into the edit CR?

From https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles edit is described as "Allows read/write access to most objects in a namespace. It does not allow viewing or modifying roles or rolebindings." So I think we need some form of read.

Note that I made a similar comment on Eventing's equivalent knative/eventing#1993 (comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, you don't need it.

The tric is that view role has the rbac.authorization.k8s.io/aggregate-to-edit label by default:

$ kubectl get clusterrole  view  --show-labels 
NAME   AGE    LABELS
view   3d2h   kubernetes.io/bootstrapping=rbac-defaults,rbac.authorization.k8s.io/aggregate-to-edit=true

So, when you added knative-serving-namespaced-view, knative-serving-namespaced-view is aggregated to view role, as well as aggregated to edit role.

You can confirm it by following steps:

// Create clusterrole 
$ cd serving
$ kubectl apply -f config/200-clusterrole-namespaced.yaml
$ kubectl get clusterrole edit -o yaml |grep -A9 serving

The edit role is supposed to have following "read" verbs.

- apiGroups:
  - serving.knative.dev
  - networking.internal.knative.dev
  - autoscaling.internal.knative.dev
  resources:
  - '*'
  verbs:
  - get
  - list
  - watch

Of course we can explicitly add the read role to knative-serving-namespaced-edit, but I feel that it is redundant.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool. Thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants