-
Notifications
You must be signed in to change notification settings - Fork 117
https://issues.redhat.com/browse/ACM-24933 part 2 #8413
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
base: 2.15_stage
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| [#create-cluster-permission] | ||
| = Creating a cluster permission | ||
|
|
||
| When the service account is created, it does not have any permission associated to it. To grant permissions to the new service account, use the `ClusterPermission` resource. Create the `ClusterPermission` resource in the managed cluster namespace on the hub cluster. Use the `ClusterPermission` resource to create roles, cluster roles resources on the managed clusters, and bind them to a service account through a `RoleBinding` or `ClusterRoleBinding` resource. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should not be using "it" so much. I recommend: By default, a service account with created without an associated permission. |
||
|
|
||
| *Required access:* Cluster administrator | ||
|
|
||
| .Prerequisites | ||
|
|
||
| - If you want to bind to the `ManagedServiceAccount` resource, you must have the `ManagedServiceAccount` add-on. For more information about enabling the `ManagedServiceAccount` add-on, see link:../add-ons/configure_klusterlet_addons.adoc[Configuring klusterlet add-ons]. | ||
| .Procedure | ||
|
|
||
| Complete the following steps to create a `ClusterPermission` resource that grants permissions to a managed service account: | ||
|
|
||
| . To grant the `<managed-sa-sample>` service account permission to the sample mortgage application that is deployed to the `mortgage` namespace on `<managed-cluster>`, create a YAML file with the following content: | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to introduce this YAML better. I would rather not have most of the file a YAML file with no explanation. We need to introduce the kind, then we should have separate steps about the roles, role bindings, etc... It's not good practice to give a large about of YAML in one step and say Create this YAML.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See here that the bindings were created in a step in 2.14 and pieces of the YAML were defined in a step or the intro: https://github.com/stolostron/rhacm-docs/blob/2.14_stage/secure_clusters/fine_grain_rbac_cli.adoc We got away from that for some reason here? |
||
| + | ||
| [source,yaml] | ||
| ---- | ||
| apiVersion: rbac.open-cluster-management.io/v1alpha1 | ||
| kind: ClusterPermission | ||
| metadata: | ||
| name: <clusterpermission-msa-subject-sample> | ||
| namespace: <managed-cluster> | ||
| spec: | ||
| roles: | ||
| - namespace: default | ||
| rules: | ||
| - apiGroups: ["apps"] | ||
| resources: ["deployments"] | ||
| verbs: ["get", "list", "create", "update", "delete", "patch"] | ||
| - apiGroups: [""] | ||
| resources: ["configmaps", "secrets", "pods", "podtemplates", "persistentvolumeclaims", "persistentvolumes"] | ||
| verbs: ["get", "update", "list", "create", "delete", "patch"] | ||
| - apiGroups: ["storage.k8s.io"] | ||
| resources: ["*"] | ||
| verbs: ["list"] | ||
| - namespace: mortgage | ||
| rules: | ||
| - apiGroups: ["apps"] | ||
| resources: ["deployments"] | ||
| verbs: ["get", "list", "create", "update", "delete", "patch"] | ||
| - apiGroups: [""] | ||
| resources: ["configmaps", "secrets", "pods", "services", "namespace"] | ||
| verbs: ["get", "update", "list", "create", "delete", "patch"] | ||
| clusterRole: | ||
| rules: | ||
| - apiGroups: ["*"] | ||
| resources: ["*"] | ||
| verbs: ["get", "list"] | ||
| roleBindings: | ||
| - namespace: default | ||
| roleRef: | ||
| kind: Role | ||
| subject: | ||
| apiGroup: authentication.open-cluster-management.io | ||
| kind: ManagedServiceAccount | ||
| name: <managed-sa-sample> | ||
| - namespace: mortgage | ||
| roleRef: | ||
| kind: Role | ||
| subject: | ||
| apiGroup: authentication.open-cluster-management.io | ||
| kind: ManagedServiceAccount | ||
| name: <managed-sa-sample> | ||
| clusterRoleBinding: | ||
| subject: | ||
| apiGroup: authentication.open-cluster-management.io | ||
| kind: ManagedServiceAccount | ||
| name: <managed-sa-sample> | ||
| ---- | ||
|
|
||
| . Save your YAML file. | ||
|
|
||
fxiang1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| . Apply your YAML file by running the following command: | ||
|
|
||
| + | ||
| [source,bash] | ||
| ---- | ||
| oc apply -f cluster-permission.yaml | ||
| ---- | ||
|
|
||
| . The sample `<clusterpermission>` creates a role called `<clusterpermission-msa-subject-sample>` in the `mortgage` namespace. If one does not already exist, create a namespace `mortgage`. | ||
| . Review the resources that are created on the `<managed-cluster>` namespace. | ||
|
|
||
| After you create the sample, `<clusterpermission>`, the following resources are created in the sample managed cluster: | ||
|
|
||
| * One `Role` called `<clusterpermission-msa-subject-sample>` in the default namespace. | ||
| * One `RoleBinding` called `<clusterpermission-msa-subject-sample>` in the default namespace for binding the role to the managed service account. | ||
| * One `Role` called `<clusterpermission-msa-subject-sample>` in the mortgage namespace. | ||
| * One `RoleBinding` called `<clusterpermission-msa-subject-sample>` in the mortgage namespace for binding the role to the managed service account. | ||
| * One `ClusterRole` called `<clusterpermission-msa-subject-sample>`. | ||
| * One `ClusterRoleBinding` called `<clusterpermission-msa-subject-sample>` for binding the `ClusterRole` to the managed service account. | ||
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.