此内容没有您所选择的语言版本。
Chapter 3. Customizing permissions by creating aggregated cluster roles
The default cluster role for the Argo CD Application Controller has a specific set of hard-coded permissions. The Red Hat OpenShift GitOps Operator manages this cluster role, so you cannot modify it. As a cluster administrator, you can customize the permissions by using any one of the following methods:
3.1. Aggregated cluster roles
By using aggregated cluster roles, you do not have to define permissions by creating new cluster roles from scratch. Instead, you can combine several cluster roles into a single one.
With Red Hat OpenShift GitOps 1.14 and later, as a cluster administrator, you can use aggregated cluster roles and enable users to easily add user-defined permissions for Argo CD Application Controller.
- The aggregated cluster roles functionality is optional and disabled by default. You can create aggregated cluster roles only for the Argo CD Application Controller component of a cluster-scoped Argo CD instance.
- 
							Deleting the aggregatedClusterRolesfield from the Argo CD custom resource (CR) does not delete the user-defined cluster role. You must manually delete the user-defined cluster role using the CLI or UI.
3.2. Prerequisites
- You understand aggregated cluster roles.
- You have installed Red Hat OpenShift GitOps on your OpenShift Container Platform cluster.
- 
						You have installed the OpenShift CLI (oc).
- 
						You have installed the Red Hat OpenShift GitOps argocdCLI.
- You have installed a cluster-scoped Argo CD instance in your defined namespace.
- You have validated that the user-defined cluster-scoped instance is configured with the cluster roles and cluster role bindings for the following components: - Argo CD Application Controller
- Argo CD server
- Argo CD ApplicationSet Controller, if ApplicationSet Controller is created
 
- You have disabled the creation of the default cluster roles for the cluster-scoped instance.
3.3. Creating aggregated cluster roles
The process of creating aggregated cluster roles consists of the following procedures:
- Enabling the creation of aggregated cluster roles
- Creating user-defined cluster roles and configuring user-defined permissions for Application Controller
3.3.1. Enable the creation of aggregated cluster roles
					You can enable the creation of aggregated cluster roles by setting the value of the .spec.aggregatedClusterRoles field to true in the Argo CD custom resource (CR). When you enable the creation of aggregated cluster roles, the Red Hat OpenShift GitOps Operator takes the following actions:
				
- 
							Creates an <argocd_name>-<argocd_namespace>-argocd-application-controlleraggregated cluster role with a predefinedaggregationRulefield by default.
- Creates a corresponding cluster role binding and manages it.
- 
							Creates and manages viewandadmincluster roles for Application Controller to add user-defined permissions into the aggregated cluster role.
					To configure user-defined permissions into the <argocd_name>-<argocd_namespace>-argocd-application-controller-admin cluster role and aggregated cluster role, you must create one or more user-defined cluster roles with the argocd/aggregate-to-admin: 'true' label and then configure the user-defined permissions for Application Controller.
				
- 
								The aggregated cluster role inherits permissions from the <argocd_name>-<argocd_namespace>-argocd-application-controller-adminand<argocd_name>-<argocd_namespace>-argocd-application-controller-viewcluster roles.
- 
								The <argocd_name>-<argocd_namespace>-argocd-application-controller-admincluster role inherits permissions from the user-defined cluster role.
3.4. Enabling the creation of aggregated cluster roles
To enable the creation of aggregated cluster roles for the Argo CD Application Controller component of a cluster-scoped Argo CD instance, you must configure the corresponding field by editing the YAML file of the Argo CD custom resource (CR).
Procedure
- In the Argo CD CR, set the value of the - .spec.aggregatedClusterRolesfield to- true:- Example Argo CD CR - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- The name of the cluster-scoped instance.
- 2
- The namespace where you want to run the cluster-scoped instance.
- 3
- The value set totrueenables the creation of aggregated cluster roles. If you do not want to enable the creation of aggregated cluster roles, either do not include this line or set the value tofalse.
 - Example output - argocd.argoproj.io/example configured - argocd.argoproj.io/example configured- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Verify that the - Statusfield of the cluster-scoped Argo CD instance shows as- Phase: Availableby running the following command:- oc describe argocd.argoproj.io/example -n spring-petclinic - $ oc describe argocd.argoproj.io/example -n spring-petclinic- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- TheAvailablestatus indicates that the cluster-scoped Argo CD instance is healthy and available.
 Note- The Red Hat OpenShift GitOps Operator creates the following default cluster roles and manages them: - 
									<argocd_name>-<argocd_namespace>-argocd-application-controlleraggregated cluster role
- 
									<argocd_name>-<argocd_namespace>-argocd-application-controller-view
- 
									<argocd_name>-<argocd_namespace>-argocd-application-controller-admin
 
- Verify that the Operator has created the default cluster roles and cluster role bindings for the Argo CD Application Controller and Argo CD server components by running the following commands: - oc get ClusterRoles -l app.kubernetes.io/part-of=argocd - $ oc get ClusterRoles -l app.kubernetes.io/part-of=argocd- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - NAME CREATED AT example-spring-petclinic-argocd-application-controller 2024-08-14T08:20:58Z example-spring-petclinic-argocd-application-controller-admin 2024-08-14T09:08:38Z example-spring-petclinic-argocd-application-controller-view 2024-08-14T09:08:38Z example-spring-petclinic-argocd-server 2024-08-14T08:20:59Z - NAME CREATED AT example-spring-petclinic-argocd-application-controller 2024-08-14T08:20:58Z example-spring-petclinic-argocd-application-controller-admin 2024-08-14T09:08:38Z example-spring-petclinic-argocd-application-controller-view 2024-08-14T09:08:38Z example-spring-petclinic-argocd-server 2024-08-14T08:20:59Z- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - oc get ClusterRoleBindings -l app.kubernetes.io/part-of=argocd - $ oc get ClusterRoleBindings -l app.kubernetes.io/part-of=argocd- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - NAME ROLE AGE example-spring-petclinic-argocd-application-controller ClusterRole/example-spring-petclinic-argocd-application-controller 54m example-spring-petclinic-argocd-server ClusterRole/example-spring-petclinic-argocd-server 54m - NAME ROLE AGE example-spring-petclinic-argocd-application-controller ClusterRole/example-spring-petclinic-argocd-application-controller 54m example-spring-petclinic-argocd-server ClusterRole/example-spring-petclinic-argocd-server 54m- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - The cluster role bindings for the - viewand- admincluster roles are not created. This is because the- viewand- admincluster roles only add permissions to the aggregated cluster role and do not directly configure permissions to the Argo CD Application Controller.Tip- Alternatively, you can use the OpenShift Container Platform web console to verify from the Administrator perspective. You can go to User Management - Roles and User Management - RoleBindings, respectively. You can search for the cluster roles and cluster role bindings that have the - app.kubernetes.io/part-of:argocdlabel.
- Verify that the aggregated cluster role is created by checking the permissions of outputs of the roles created by running the following command: - oc get ClusterRole/<cluster_role_name> -o yaml - $ oc get ClusterRole/<cluster_role_name> -o yaml- 1 - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Replace<cluster_role_name>with the name of the role created.
 - Example output of the aggregated cluster role - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- The name of the aggregated cluster role.
- 2
- The predefined list of labels indicates that the aggregated cluster role can inherit permissions from the other user-defined cluster roles.
- 3
- No predefined permissions are set. However, when the Operator immediately creates a<argocd_name>-<argocd_namespace>-argocd-application-controller-viewcluster role, the corresponding predefinedviewpermissions are added into the aggregated cluster role.
 - Example output of the - viewcluster role- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output of the - admincluster role- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- The labels match the predefined list of an existing aggregated cluster role.
- 2
- The name of theadmincluster role.
- 3
- The predefined list of labels indicates that the existing<argocd_name>-<argocd_namespace>-argocd-application-controller-admincluster role can inherit permissions from the other user-defined cluster roles.
- 4
- Specifies that no permissions are defined yet in one or more user-defined cluster roles.
 Tip- Alternatively, you can use the OpenShift Container Platform web console to verify from the Administrator perspective. You can go to User Management - Roles, use the Filter option, select Cluster-wide Roles, and search for the aggregated cluster role, - view, and- admincluster roles. You must open the cluster role to check the details and configurations.- As a cluster administrator, you can now create one or more user-defined cluster roles and configure user-defined permissions for Argo CD Application Controller. 
As a cluster administrator, to add user-defined permissions to your aggregated cluster role, you must create one or more user-defined cluster roles and then configure the user-defined permissions for the Argo CD Application Controller component of a cluster-scoped Argo CD instance.
Prerequisites
- You have enabled the creation of aggregated cluster roles for the Argo CD Application Controller component of a cluster-scoped Argo CD instance.
- You have the following default cluster roles that are created and managed by the Red Hat OpenShift GitOps Operator: - 
								<argocd_name>-<argocd_namespace>-argocd-application-controlleraggregated cluster role with a predefinedaggregationRulefield
- 
								<argocd_name>-<argocd_namespace>-argocd-application-controller-viewwith predefinedviewpermissions
- 
								<argocd_name>-<argocd_namespace>-argocd-application-controller-adminwith no predefined permissions
 
- 
								
Procedure
- Create a new cluster role with the required labels and permissions by using the following command: - oc apply -n <namespace> -f <cluster_role_name>.yaml - $ oc apply -n <namespace> -f <cluster_role_name>.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - where: - <namespace>
- Specifies the name of your defined namespace.
- <cluster_role_name>
- Specifies the name of your defined cluster role YAML file. - Example user-defined cluster role YAML - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- The name of the user-defined cluster role.
- 2
- The labels match the predefined list of an existing<argocd_name>-<argocd_namespace>-argocd-application-controller-admincluster role.
- 3
- The user-defined permissions that are to be added into the aggregated cluster role through the<argocd_name>-<argocd_namespace>-argocd-application-controller-admincluster role.
 Tip- Alternatively, you can use the web console to create a user-defined cluster role from the Administrator perspective. You can go to User Management - Roles - Create Role, use the preceding YAML template to add permissions, and click Create. - Example output - clusterrole.rbac.authorization.k8s.io/user-application-controller created - clusterrole.rbac.authorization.k8s.io/user-application-controller created- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - A user-defined cluster role is created. 
 
- Verify that the - <argocd_name>-<argocd_namespace>-argocd-application-controller-admincluster role inherits permissions from the user-defined cluster role by running the following command:- oc get ClusterRole/<argocd_name>-<argocd_namespace>-argocd-application-controller-admin -o yaml - $ oc get ClusterRole/<argocd_name>-<argocd_namespace>-argocd-application-controller-admin -o yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - where: - <argocd_name>
- Specifies the name of your user-defined cluster-scoped Argo CD instance.
- <argocd_namespace>
- Specifies the namespace where Argo CD is installed. - Example output - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow Tip- Alternatively, you can use the OpenShift Container Platform web console to verify from the Administrator perspective. You can go to User Management - Roles, use the Filter option, select Cluster-wide Roles, and search for the - <argocd_name>-<argocd_namespace>-argocd-application-controller-admincluster role. You must open the cluster role to check the details and configurations.
 
- Verify that the - <argocd_name>-<argocd_namespace>-argocd-application-controlleraggregated cluster role inherits permissions from the- <argocd_name>-<argocd_namespace>-argocd-application-controller-adminand- <argocd_name>-<argocd_namespace>-argocd-application-controller-viewcluster roles by running the following command:- oc get ClusterRole/<argocd_name>-<argocd_namespace>-argocd-application-controller -o yaml - $ oc get ClusterRole/<argocd_name>-<argocd_namespace>-argocd-application-controller -o yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - where: - <argocd_name>
- Specifies the name of your user-defined cluster-scoped Argo CD instance.
- <argocd_namespace>
- Specifies the namespace where Argo CD is installed. - Example output of the aggregated cluster role - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow Tip- Alternatively, you can use the OpenShift Container Platform web console to verify from the Administrator perspective. You can go to User Management - Roles, use the Filter option, select Cluster-wide Roles, and search for the aggregated cluster role. You must open the cluster role to check the details and configurations.