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

Account for discovered policies(kyverno, vapb etc) in aggregaterole #1907

Conversation

yiraeChristineKim
Copy link
Contributor

@yiraeChristineKim yiraeChristineKim commented Jan 9, 2025

Description

This will allow the discovered policies table to show kyverno policies(clusterPolicy, policy), gatekeeper mutations, validatingAdmissionPolicyBinding, policyreports for view users.

Related Issue

https://issues.redhat.com/browse/ACM-16116
https://issues.redhat.com/browse/ACM-16959

Changes Made

Add roles (gatekeeper mutation, kyverno policies, clusterpolicyReport)

Checklist

  • I have tested the changes locally and they are functioning as expected.
  • I have updated the documentation (if necessary) to reflect the changes.
  • I have added/updated relevant unit tests (if applicable).
  • I have ensured that my code follows the project's coding standards.
  • I have checked for any potential security issues and addressed them.
  • I have added necessary comments to the code, especially in complex or unclear sections.
  • I have rebased my branch on top of the latest main/master branch.

Additional Notes

Related: #1723

Reviewers

@JustinKuli @dhaiducek @gparvin

Definition of Done

  • Code is reviewed.
  • Code is tested.
  • Documentation is updated.
  • All checks and tests pass.
  • Approved by at least one reviewer.
  • Merged into the main/master branch.

Copy link

openshift-ci bot commented Jan 9, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@yiraeChristineKim yiraeChristineKim force-pushed the dicovered-kyverno-gatekeeper-vapb branch 2 times, most recently from ea72ae6 to 1eab00b Compare January 9, 2025 18:14
@yiraeChristineKim
Copy link
Contributor Author

/cc @pshickeydev @joeg-pro

@openshift-ci openshift-ci bot requested review from joeg-pro and pshickeydev January 9, 2025 18:18
@yiraeChristineKim yiraeChristineKim marked this pull request as ready for review January 9, 2025 18:18
@openshift-ci openshift-ci bot requested a review from cameronmwall January 9, 2025 18:18
@yiraeChristineKim
Copy link
Contributor Author

resources: ["*"]
verbs: ["create", "get", "list", "watch", "update", "delete", "deletecollection", "patch"]
- apiGroups: ["admissionregistration.k8s.io"]
resources: ["validatingadmissionpolicybindings"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Only bindings? Or should these include just validatingadmissionpolicy?

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 don't show validatingadmissionpolicy in discovered policy so

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added! Thanks validatingadmissionpolicy is connected to validatingadmissionpolicybindings so it is good to add this! Thanks!!

verbs: ["create", "get", "list", "watch", "update", "delete", "deletecollection", "patch"]
- apiGroups: ["kyverno.io"]
resources: ["policies", "clusterpolicies"]
verbs: ["create", "get", "list", "watch", "update", "delete", "deletecollection", "patch"]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Missing trailing newline

verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: ["admissionregistration.k8s.io"]
resources: ["validatingadmissionpolicybindings"]
verbs: ["get", "list", "watch", "update", "patch"]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Missing trailing newline

verbs: ["get", "list", "watch"]
- apiGroups: ["kyverno.io"]
resources: ["policies", "clusterpolicies"]
verbs: ["get", "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.

nit: Missing trailing newline

verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: ["admissionregistration.k8s.io"]
resources: ["validatingadmissionpolicybindings"]
verbs: ["get", "list", "watch", "update", "patch"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this have Kvyerno also?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean validatingadmissionpolicybindings has kyverno?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, sorry the lines here are unrelated. I mean kyverno.io is missing in the edit role.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed Thanks!

Comment on lines 41 to 43
- apiGroups: ["kyverno.io"]
resources: ["policies", "clusterpolicies"]
verbs: ["create", "get", "list", "watch", "update", "delete", "deletecollection", "patch"]
Copy link
Contributor

Choose a reason for hiding this comment

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

I could be swayed on Gatekeeper since Gatekeeper is included in an ACM subscription, but I'm not sure these permissions should allow anything other than a fetch for Kyverno objects since ACM doesn't include/support Kyverno.

Suggested change
- apiGroups: ["kyverno.io"]
resources: ["policies", "clusterpolicies"]
verbs: ["create", "get", "list", "watch", "update", "delete", "deletecollection", "patch"]
- apiGroups: ["kyverno.io"]
resources: ["policies", "clusterpolicies"]
verbs: ["get", "list", "watch"]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point! Who should I ask this?

Copy link
Contributor

Choose a reason for hiding this comment

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

You could ask @gparvin?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm ok with get, list and watch but I don't think we want to go beyond those. What are we trying to do that needs more than just reading their 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.

@gparvin you are right. We need list, get (+watch maybe) to display on discovered policy table

Copy link
Contributor

Choose a reason for hiding this comment

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

@yiraeChristineKim Did we need more than get/list/watch on the other resources? Make sure you are requesting the least amount of permissions possible to reduce the possibility of security issues in this area.

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 get, list, and watch, but I primarily want to ensure compatibility with this PR. I am not entirely sure how the ClusterRole is being used

@yiraeChristineKim yiraeChristineKim force-pushed the dicovered-kyverno-gatekeeper-vapb branch 3 times, most recently from d6f7706 to e48a233 Compare January 9, 2025 19:30
Copy link
Contributor

@dhaiducek dhaiducek left a comment

Choose a reason for hiding this comment

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

LGTM!

@openshift-ci openshift-ci bot added the lgtm label Jan 9, 2025
verbs: ["get", "list", "watch"]
- apiGroups: ["submarineraddon.open-cluster-management.io"]
resources: ["submarinerconfigs", "submarinerconfigs/status"]
verbs: ["create", "get", "list", "watch", "update", "delete", "deletecollection", "patch"]
- apiGroups: ["mutations.gatekeeper.sh"]
resources: ["*"]
verbs: ["create", "get", "list", "watch", "update", "delete", "deletecollection", "patch"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Double check whether get, list, watch is enough.

verbs: ["create", "get", "list", "watch", "update", "delete", "deletecollection", "patch"]
- apiGroups: ["admissionregistration.k8s.io"]
resources: ["validatingadmissionpolicybindings", "validatingadmissionpolicies"]
verbs: ["create", "get", "list", "watch", "update", "delete", "deletecollection", "patch"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Double check whether get, list, watch is enough. In the future I expect we could begin adopting VAP in the hub once it's supported across the OCP releases we run on, but for now I'm not sure why we would want the extra permissions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so only get, list, watch? I am not sure why #1723 added extra verb to gatekeeper constraint

verbs: ["get", "list", "watch"]
- apiGroups: ["submarineraddon.open-cluster-management.io"]
resources: ["submarinerconfigs", "submarinerconfigs/status"]
verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: ["mutations.gatekeeper.sh"]
Copy link
Contributor

Choose a reason for hiding this comment

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

If RBAC is reduced above, make sure update and patch are removed here too.

This will allow the discovered policies table to show kyverno policies(clusterPolicy, policy), gatekeeper mutations, validatingAdmissionPolicyBinding, policyreports
for view users.

Signed-off-by: yiraeChristineKim <[email protected]>
@yiraeChristineKim yiraeChristineKim force-pushed the dicovered-kyverno-gatekeeper-vapb branch from e48a233 to 535ee2c Compare January 13, 2025 18:25
@openshift-ci openshift-ci bot removed the lgtm label Jan 13, 2025
Copy link
Contributor

@gparvin gparvin left a comment

Choose a reason for hiding this comment

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

Thank you!

Copy link

openshift-ci bot commented Jan 13, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dhaiducek, gparvin, yiraeChristineKim

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

@openshift-merge-bot openshift-merge-bot bot merged commit a215cef into stolostron:main Jan 13, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants