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 notes for addon template permission setting #424

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions content/en/developer-guides/addon.md
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,40 @@ volumes, health probe for daemonsets) from OCM v0.14.0.
name: ca-secret
```

**Notes**:

* The permission related resources(i.e. `RoleBinding` `ClusterRoleBinding`) for *the addon agent access the local
managed cluster* defined in the `addonTemplate.agentSpec.workload.manifests` will be created on the managed cluster
by the work-agent, but the work-agent may not have permission to create these resources, users should refer to
[permission-setting-for-work-agent](../concepts/manifestwork.md#permission-setting-for-work-agent) to grant the
work-agnet permissions to address the permission issue on the managed cluster side.
* Permissions for *the addon agent access the hub cluster* defined in
`addonTemplate.registration[*].kubeClient.hubPermissions`, users should ensure:
1) the referenced clusterrole/role(`.hubPermissions.currentCluster.clusterRoleName`
`.hubPermissions.singleNamespace.roleRef.name`, `cm-admin` and `cm-reader` in the above example) exists on the
hub cluster
2) the addon-manager has permission to create rolebinding to bind these (cluster)role for the addon-agent. For
example: users can create a clusterrolebinding to grant the permission to the addon-manager (service account
`open-cluster-management-hub/addon-manager-controller-sa`) to address the permission issue on the hub cluster
side. For the above example, if the addon-manager doesn't have the permission to create the `RoleBinding` to
bind the `cm-admin` role, users can grant the permission to the addon-manager by creating a
`ClusterRoleBinding` like below:

```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: addon-manager-cm-admin
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cm-admin
subjects:
- kind: ServiceAccount
name: addon-manager-controller-sa
namespace: open-cluster-management-hub
```

Copy link
Member

Choose a reason for hiding this comment

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

could here use the template role cm-admin cm-reader as an example, to add a clusterrolebinding example after step3.

Copy link
Member

Choose a reason for hiding this comment

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

The beginner usually copies the example yaml we provide and do some modification.

Copy link
Member Author

Choose a reason for hiding this comment

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

PTAL

Copy link

@z1ens z1ens Jul 4, 2024

Choose a reason for hiding this comment

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

In line 1126 permission-setting-for-work-agent

Here the link seems like not valid when clicking it on the OCM website.

Copy link
Member Author

Choose a reason for hiding this comment

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

2. Create a `ClusterManagementAddOn` to declare this is template type addon which should be managed by the
addon-manager:

Expand Down
34 changes: 34 additions & 0 deletions content/zh/developer-guides/addon.md
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,40 @@ volumes, health probe for daemonsets) from OCM v0.14.0.
name: ca-secret
```

**Notes**:

* The permission related resources(i.e. `RoleBinding` `ClusterRoleBinding`) for *the addon agent access the local
managed cluster* defined in the `addonTemplate.agentSpec.workload.manifests` will be created on the managed cluster
by the work-agent, but the work-agent may not have permission to create these resources, users should refer to
[permission-setting-for-work-agent](../concepts/manifestwork.md#permission-setting-for-work-agent) to grant the
work-agnet permissions to address the permission issue on the managed cluster side.
* Permissions for *the addon agent access the hub cluster* defined in
`addonTemplate.registration[*].kubeClient.hubPermissions`, users should ensure:
1) the referenced clusterrole/role(`.hubPermissions.currentCluster.clusterRoleName`
`.hubPermissions.singleNamespace.roleRef.name`, `cm-admin` and `cm-reader` in the above example) exists on the
hub cluster
2) the addon-manager has permission to create rolebinding to bind these (cluster)role for the addon-agent. For
example: users can create a clusterrolebinding to grant the permission to the addon-manager (service account
`open-cluster-management-hub/addon-manager-controller-sa`) to address the permission issue on the hub cluster
side. For the above example, if the addon-manager doesn't have the permission to create the `RoleBinding` to
bind the `cm-admin` role, users can grant the permission to the addon-manager by creating a
`ClusterRoleBinding` like below:

```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: addon-manager-cm-admin
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cm-admin
subjects:
- kind: ServiceAccount
name: addon-manager-controller-sa
namespace: open-cluster-management-hub
```

2. Create a `ClusterManagementAddOn` to declare this is template type addon which should be managed by the
addon-manager:

Expand Down
Loading