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

Grant deployment manager server account permissions to read managed clusters and secrets #82

Conversation

jhernand
Copy link
Collaborator

@jhernand jhernand commented Apr 9, 2024

The service account that is used to run the deployment manager server needs permissions to read ManagedCluster objects and assisted installer admin kubeconfig secrets. This patch changes the operator so that it creates the corresponding cluster roles and cluster role bindings. In order to do so the operator needs to also have those permissions, as Kubernetes forbids granting more permissions than the service account granting them already has. So this patch also adds those permissions to the service account that is used to run the operator.

@openshift-ci openshift-ci bot requested review from danielerez and irinamihai April 9, 2024 18:48
@jhernand jhernand force-pushed the grant_deployment_manager_server_account_permissions_to_read_managed_clusters_and_secrets branch 3 times, most recently from 0d18c0d to 6e84e45 Compare April 9, 2024 19:01
@@ -9,5 +9,5 @@ generatorOptions:

images:
- name: controller
newName: quay.io/jhernand/o2ims-operator
newTag: "2"
newName: quay.io/imihai/oran-o2ims-operator
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we change this to the final name which would be quay.io/openshift-kni/oran-o2ims-operator?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, will do.

roleName := fmt.Sprintf("%s-%s", orano2ims.Namespace, utils.ORANO2IMSAlarmSubscriptionServerName)
bindingName := fmt.Sprintf("%s-%s", orano2ims.Namespace, utils.ORANO2IMSAlarmSubscriptionServerName)

// Grant the service account permissions to read the objects it needs, for example managed
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could consider moving the creation of the ClusterRole & ClusterRoleBinding to their own functions, like for the other resources create by the operator.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, makes sense, will do it.


// Grant the service account permissions to read the objects it needs, for example managed
// clusters:
role := &rbacv1.ClusterRole{
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be a good idea to use the utils.CreateK8sCR function for creating these new resources for 2 reasons:

  1. It sets the owner resource, so when the orano2ims CR is deleted, these resources will also be deleted.
  2. If anyone is to update these resources, the operator will PATCH/UPDATE them to the expected values so that everything works as expected.

Please ignore these if they are not relevant to what you had in mind.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree, will do it.

This patch regenerates manifest files generated by `make generate` and
`make bundle`.

Signed-off-by: Juan Hernandez <[email protected]>
The service account that is used to run the deployment manager server
needs permissions to read `ManagedCluster` objects and assisted
installer admin kubeconfig secrets. This patch changes the operator so
that it creates the corresponding cluster roles and cluster role
bindings. In order to do so the operator needs to also have those
permissions, as Kubernetes forbids granting more permissions than the
service account granting them already has. So this patch also adds those
permissions to the service account that is used to run the operator.

Signed-off-by: Juan Hernandez <[email protected]>
@jhernand jhernand force-pushed the grant_deployment_manager_server_account_permissions_to_read_managed_clusters_and_secrets branch from 6e84e45 to 010cea8 Compare April 11, 2024 18:08
@jhernand
Copy link
Collaborator Author

@irinamihai I think I addressed all your suggestions, please take another look.

@irinamihai
Copy link
Collaborator

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 11, 2024
@irinamihai
Copy link
Collaborator

/approve

Copy link

openshift-ci bot commented Apr 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: irinamihai

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-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 11, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 7f7ba92 into openshift-kni:main Apr 11, 2024
8 checks passed
@jhernand jhernand deleted the grant_deployment_manager_server_account_permissions_to_read_managed_clusters_and_secrets branch April 11, 2024 19:05
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. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants