Access control and user management
Configuring user authentication and access controls for users and namespaces
Abstract
Chapter 1. Configuring Argo CD RBAC Copy linkLink copied to clipboard!
By default, if you are logged into Argo CD using Red Hat SSO (RH SSO), you are a read-only user. You can change and manage the user level access.
1.1. Configuring user level access Copy linkLink copied to clipboard!
To manage and modify the user level access, configure the role-based access control (RBAC) section in the Argo CD custom resource (CR).
Procedure
Edit the
argocdCR:oc edit argocd [argocd-instance-name] -n [namespace]
$ oc edit argocd [argocd-instance-name] -n [namespace]Copy to Clipboard Copied! Toggle word wrap Toggle overflow Output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
policyconfiguration to therbacsection and add thename,emailand theroleof the user:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Currently, RHSSO cannot read the group information of Red Hat OpenShift GitOps users. Therefore, configure the RBAC at the user level.
1.2. Modifying RHSSO resource requests/limits Copy linkLink copied to clipboard!
By default, the RHSSO container is created with resource requests and limitations. You can change and manage the resource requests.
| Resource | Requests | Limits |
|---|---|---|
| CPU | 500 | 1000m |
| Memory | 512 Mi | 1024 Mi |
Procedure
- Modify the default resource requirements patching the Argo CD custom resource (CR):
oc -n openshift-gitops patch argocd openshift-gitops --type='json' -p='[{"op": "add", "path": "/spec/sso", "value": {"provider": "keycloak", "resources": {"requests": {"cpu": "512m", "memory": "512Mi"}, "limits": {"cpu": "1024m", "memory": "1024Mi"}} }}]'
$ oc -n openshift-gitops patch argocd openshift-gitops --type='json' -p='[{"op": "add", "path": "/spec/sso", "value": {"provider": "keycloak", "resources": {"requests": {"cpu": "512m", "memory": "512Mi"}, "limits": {"cpu": "1024m", "memory": "1024Mi"}} }}]'
RHSSO created by the Red Hat OpenShift GitOps only persists the changes that are made by the operator. If the RHSSO restarts, any additional configuration created by the Admin in RHSSO is deleted.
Chapter 2. Configuring SSO for Argo CD using Dex Copy linkLink copied to clipboard!
After the Red Hat OpenShift GitOps Operator is installed, Argo CD automatically creates a user with admin permissions. To manage multiple users, cluster administrators can use Argo CD to configure Single Sign-On (SSO).
The spec.dex parameter in the ArgoCD CR is deprecated. In a future release of Red Hat OpenShift GitOps v1.10.0, configuring Dex using the spec.dex parameter in the ArgoCD CR is planned to be removed. Consider using the .spec.sso parameter instead.
2.1. Configuration to enable the Dex OpenShift OAuth Connector Copy linkLink copied to clipboard!
Dex is installed by default for all the Argo CD instances created by the Operator. Dex uses the users and groups defined within OpenShift by checking the OAuth server provided by the platform. You can configure the options for the Dex SSO provider. The following example shows the properties of Dex along with example configurations:
- 1
- The
openShiftOAuthproperty triggers the Operator to automatically configure the built-in OpenShiftOAuthserver when the value is set totrue. - 2
- The
groupsproperty allows users of the specified group(s) to log in. - 3
- The RBAC policy property assigns the admin role in the Argo CD cluster to users in the OpenShift
cluster-adminsgroup.
2.1.1. Mapping users to specific roles Copy linkLink copied to clipboard!
Argo CD cannot map users to specific roles if they have a direct ClusterRoleBinding role. You can manually change the role as role:admin on SSO through OpenShift.
Procedure
Create a group named
cluster-admins.oc adm groups new cluster-admins
$ oc adm groups new cluster-adminsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the user to the group.
oc adm groups add-users cluster-admins USER
$ oc adm groups add-users cluster-admins USERCopy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the
cluster-adminClusterRoleto the group:oc adm policy add-cluster-role-to-group cluster-admin cluster-admins
$ oc adm policy add-cluster-role-to-group cluster-admin cluster-adminsCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2. Disabling Dex Copy linkLink copied to clipboard!
Dex is installed by default for all the Argo CD instances created by the Operator. You can configure Red Hat OpenShift GitOps to use Dex as the SSO authentication provider by setting the .spec.dex parameter.
In Red Hat OpenShift GitOps v1.6.0, DISABLE_DEX is deprecated and is planned to be removed in Red Hat OpenShift GitOps v1.10.0. Consider using the .spec.sso.dex parameter instead. See "Enabling or disabling Dex using .spec.sso".
Procedure
Set the environmental variable
DISABLE_DEXtotruein the YAML resource of the Operator:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.3. Enabling or disabling Dex using .spec.sso Copy linkLink copied to clipboard!
You can configure Red Hat OpenShift GitOps to use Dex as its SSO authentication provider by setting the .spec.sso parameter.
Procedure
To enable Dex, set the
.spec.sso.provider: dexparameter in the YAML resource of the Operator:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
To disable dex, either remove the
spec.ssoelement from the Argo CD custom resource, or specify a different SSO provider.
Chapter 3. Configuring SSO for Argo CD using Keycloak Copy linkLink copied to clipboard!
After the Red Hat OpenShift GitOps Operator is installed, Argo CD automatically creates a user with admin permissions. To manage multiple users, cluster administrators can use Argo CD to configure Single Sign-On (SSO).
3.1. Prerequisites Copy linkLink copied to clipboard!
- Red Hat SSO is installed on the cluster.
- Red Hat OpenShift GitOps Operator is installed on the cluster.
- Argo CD is installed on the cluster.
3.2. Configuring a new client in Keycloak Copy linkLink copied to clipboard!
Dex is installed by default for all the Argo CD instances created by the Operator. However, you can delete the Dex configuration and add Keycloak instead to log in to Argo CD using your OpenShift credentials. Keycloak acts as an identity broker between Argo CD and OpenShift.
Procedure
To configure Keycloak, follow these steps:
Delete the Dex configuration by removing the
.spec.sso.dexparameter from the Argo CD custom resource (CR), and save the CR:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the value of the
providerparameter tokeycloakin the Argo CD CR. Configure Keycloak by performing one of the following steps:
For a secure connection, set the value of the
rootCAparameter as shown in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- A custom certificate used to verify the Keycloak’s TLS certificate.
The Operator reconciles changes in the
.spec.keycloak.rootCAparameter and updates theoidc.configparameter with the PEM encoded root certificate in theargocd-cmconfiguration map.For an insecure connection, leave the value of the
rootCAparameter empty and use theoidc.tls.insecure.skip.verifyparameter as shown below:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The Keycloak instance takes 2-3 minutes to install and run.
3.3. Logging in to Keycloak Copy linkLink copied to clipboard!
Log in to the Keycloak console to manage identities or roles and define the permissions assigned to the various roles.
Prerequisites
- The default configuration of Dex is removed.
- Your Argo CD CR must be configured to use the Keycloak SSO provider.
Procedure
Get the Keycloak route URL for login:
oc -n argocd get route keycloak NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD keycloak keycloak-default.apps.ci-ln-******.origin-ci-int-aws.dev.**.com keycloak <all> reencrypt None
$ oc -n argocd get route keycloak NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD keycloak keycloak-default.apps.ci-ln-******.origin-ci-int-aws.dev.**.com keycloak <all> reencrypt NoneCopy to Clipboard Copied! Toggle word wrap Toggle overflow Get the Keycloak pod name that stores the user name and password as environment variables:
oc -n argocd get pods NAME READY STATUS RESTARTS AGE keycloak-1-2sjcl 1/1 Running 0 45m
$ oc -n argocd get pods NAME READY STATUS RESTARTS AGE keycloak-1-2sjcl 1/1 Running 0 45mCopy to Clipboard Copied! Toggle word wrap Toggle overflow Get the Keycloak user name:
oc -n argocd exec keycloak-1-2sjcl -- "env" | grep SSO_ADMIN_USERNAME SSO_ADMIN_USERNAME=Cqid54Ih
$ oc -n argocd exec keycloak-1-2sjcl -- "env" | grep SSO_ADMIN_USERNAME SSO_ADMIN_USERNAME=Cqid54IhCopy to Clipboard Copied! Toggle word wrap Toggle overflow Get the Keycloak password:
oc -n argocd exec keycloak-1-2sjcl -- "env" | grep SSO_ADMIN_PASSWORD SSO_ADMIN_PASSWORD=GVXxHifH
$ oc -n argocd exec keycloak-1-2sjcl -- "env" | grep SSO_ADMIN_PASSWORD SSO_ADMIN_PASSWORD=GVXxHifHCopy to Clipboard Copied! Toggle word wrap Toggle overflow
On the login page, click LOG IN VIA KEYCLOAK.
NoteYou only see the option LOGIN VIA KEYCLOAK after the Keycloak instance is ready.
Click Login with OpenShift.
NoteLogin using
kubeadminis not supported.- Enter the OpenShift credentials to log in.
Optional: By default, any user logged in to Argo CD has read-only access. You can manage the user level access by updating the
argocd-rbac-cmconfig map:policy.csv: <name>, <email>, role:admin
policy.csv: <name>, <email>, role:adminCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.4. Uninstalling Keycloak Copy linkLink copied to clipboard!
You can delete the Keycloak resources and their relevant configurations by removing the SSO field from the Argo CD Custom Resource (CR) file. After you remove the SSO field, the values in the file look similar to the following:
A Keycloak application created by using this method is currently not persistent. Additional configurations created in the Argo CD Keycloak realm are deleted when the server restarts.