-
Notifications
You must be signed in to change notification settings - Fork 507
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
[operator] perform true "can_i" check to confirm the operator has correct permissions #3241
Comments
The kubernetes collections API has been updated and now fixes that bug. See: ansible-collections/community.kubernetes#237 We just need to put a newer version of the collection into our operator image. Would require some additions to the Dockerfile. |
This should be the list of tasks to replace the current hack - though currently I can't get it to work with the latest 1.1.1 of the community.kubernetes library:
|
This requires the operator to be given "list" permission to "SelfSubjectAccessReview". |
If we implement this, it means we removed the hack of creating the dummy roles - in that case we can turn back on dependent resource watching. We turned that off because the hack causes infinite reconciliation loops due to the hack. |
when the new collectons.kubernetes library is available, we can implement this. |
… needs for clusterrole/binding creation fixes: kiali/kiali#3241
… needs for clusterrole/binding creation part of fix for: kiali/kiali#3241
… needs for clusterrole/binding creation part of fix for: kiali/kiali#3241
… needs for clusterrole/binding creation fixes: kiali/kiali#3241
And I still think we can't do this yet... it looks like even Ansible Operator SDK 4.7.0, 4.8.0, and 4.9.0 do not have the latest community.kubernetes that we need:
It has 0.11.1 and we need at least 1.1 (see the commit where the bug fix went in - you can see it went in 1.1.0 - ansible-collections/community.kubernetes@0f3fef9) I did try it with PRs kiali/helm-charts#70 and kiali/kiali-operator#307 and I got the same error. Oh well. We'll wait another couple months... at least we have the draft PRs to show how it should be done. |
… needs for clusterrole/binding creation part of fix for: kiali/kiali#3241
… needs for clusterrole/binding creation fixes: kiali/kiali#3241
"4.8" now has 1.2.1:
"4.7" is still at 0.11. Looks like we'll need to bump up to get this.
|
This will help: #4094 But realize that downstream releases of ansible operator sdk are only up to 4.7 - we should wait until 4.8 is released. |
we can do this now as even the redhat registry published the 4.8 sdk: https://catalog.redhat.com/software/containers/openshift4/ose-ansible-operator/5cdc9a53bed8bd5717d6345e?tag=all
And quay:
|
… needs for clusterrole/binding creation fixes: kiali/kiali#3241
… needs for clusterrole/binding creation part of fix for: kiali/kiali#3241
… needs for clusterrole/binding creation fixes: kiali/kiali#3241
… needs for clusterrole/binding creation fixes: kiali/kiali#3241
To test, build and install using these PRs:
The steps to test this are simple and documented here: kiali/kiali-operator#307 (comment) |
… needs (#307) * add true can-i check to make sure the operator has the permissions it needs for clusterrole/binding creation fixes: kiali/kiali#3241 * this just logs the warning but doesn't abort. For some reason, this thinks the permission doesn't exist, but it does (the reconciliation succesfully finishes) * fix it
… needs for clusterrole/binding creation (#70) part of fix for: kiali/kiali#3241
If a Kiali CR setting
deployment.accessible_namespaces
is set to["**"]
then the operator needs permissions to create and delete ClusterRole and ClusterRoleBinding resources. The operator will check that it has these permissions and abort the Kiali installation if it does not. We do this because a user may have opted to not install the operator with those "super-power" permissions (some users may not want to give the operator service account permissions to create clusterroles/bindings - see how they can do that here) - in that case, the user cannot specify["**"]
as the value todeployment.accessible_namespaces
.The proper way for the operator to check to see if it has the necessary permissions would be for the operator to create a SelfSubjectAccessReview and look at the resulting status field to determine if it has those permissions - this is what I call a true "can_i" check as documented here.
In Ansible, the way you should be able to do this is via something like the following (this checks for create-clusterroles permission; an analogous one would be performed for create-clusterrolebindings permission):
Looking at the resulting
can_i_create_clusterroles
object (specifically itsstatus
field) will tell you if that permission exists or not.However, there is a bug in the kubernetes collection task
k8s
that causes that mechanism to not work. Therefore, today the operator performs a hack introduced by PR kiali/kiali-operator#137 - it actually creates (or at least attempts to create) a dummy ClusterRole and dummy ClusterRoleBinding. If the creation is successful, the operator knows it has the proper permissions; if the creation for either one of those fails, the operator knows it does not have the proper permissions and aborts the installation of Kiali. The operator will immediately delete any of those two dummy resources that it managed to successfully create. The code is in kiali-deploy/tasks/main.yml - do a search forkiali-dummy
and you'll see it.Of course, this is a hack. We should be using a true "can-i" check. So this issue is to document the fact that we want to wait for that bug to be fixed and when it is fixed we want to go in and remove that hack and replace it with a true "can_i" check using the resource SelfSubjectAccessReview as explained above.
The text was updated successfully, but these errors were encountered: