|
| 1 | +--- |
| 2 | +description: Create, scope, and export Calico Enterprise roles from the web console instead of writing Kubernetes RBAC manifests by hand. |
| 3 | +--- |
| 4 | + |
| 5 | +import IconUser from '/img/icons/user-icon.svg'; |
| 6 | + |
| 7 | +# Manage roles in the web console |
| 8 | + |
| 9 | +## Big picture |
| 10 | + |
| 11 | +Create and scope $[prodname] roles from the **Manage Team** page in the web console, instead of writing Kubernetes RBAC manifests by hand. |
| 12 | + |
| 13 | +## Value |
| 14 | + |
| 15 | +Giving a team access to one tier, one namespace, or one web console feature normally means hand-writing `ClusterRole` and `ClusterRoleBinding` manifests, and knowing which $[prodname] API resources each feature reads. **Manage Team** turns that into a list of named permissions: you pick what a role can view or modify and where it applies, and $[prodname] writes and reconciles the underlying Kubernetes RBAC for you. |
| 16 | + |
| 17 | +## Concepts |
| 18 | + |
| 19 | +### A role is a Kubernetes group |
| 20 | + |
| 21 | +A role you create in the console is a Kubernetes **group name**. $[prodname] binds the permissions you select to that group using `ClusterRoleBindings`, or `RoleBindings` for permissions you scope to a namespace. Everything it writes is labeled `app.kubernetes.io/managed-by=calico-ui-rbac`. |
| 22 | + |
| 23 | +A user gets a role when their authenticated identity carries that group. The console does not create or invite users: the **Users** tab is read-only, and lists the subjects it finds on the roles' bindings and in any bound identity provider groups, with the roles in effect for each. |
| 24 | + |
| 25 | +### Role management is per cluster |
| 26 | + |
| 27 | +Role management is off by default and is turned on one cluster at a time, including each managed cluster in a multi-cluster deployment. Roles are local to the cluster they were created on and are not synchronized; use **Export YAML** to copy them to another cluster. |
| 28 | + |
| 29 | +## Before you begin |
| 30 | + |
| 31 | +**Required** |
| 32 | + |
| 33 | +- A cluster running $[prodname] 3.24.0-3.0 or later |
| 34 | +- [Access to the web console](access-the-manager.mdx) as a user bound to `tigera-network-admin` |
| 35 | + |
| 36 | +**Limitations** |
| 37 | + |
| 38 | +- Roles do not synchronize between clusters. Exported roles are a copy, not a link. |
| 39 | + |
| 40 | +## How to |
| 41 | + |
| 42 | +- [Turn on role management](#turn-on-role-management) |
| 43 | +- [Create a role](#create-a-role) |
| 44 | +- [Give a user a role](#give-a-user-a-role) |
| 45 | +- [Bind roles to identity provider groups](#bind-roles-to-identity-provider-groups) |
| 46 | +- [See who has access](#see-who-has-access) |
| 47 | +- [Copy roles to another cluster](#copy-roles-to-another-cluster) |
| 48 | + |
| 49 | +### Turn on role management |
| 50 | + |
| 51 | +1. In the web console, select the cluster you want to manage roles on. |
| 52 | +1. Click the user icon <IconUser width="20"/> > **Manage Team**. |
| 53 | +1. Click **Enable RBAC management**. |
| 54 | + |
| 55 | +$[prodname] sets `rbac-ui-enabled` to `true` in the `rbac-ui-config` ConfigMap in the `calico-system` namespace, then builds the catalogue of permissions. This takes a few seconds, after which the **Roles** and **Users** tabs appear. |
| 56 | + |
| 57 | +To turn role management off again, set the flag back to `false`; the console has no control for this. Roles you already created keep working, but are no longer manageable from the console. |
| 58 | + |
| 59 | +```bash |
| 60 | +kubectl get configmap rbac-ui-config -n calico-system -o json \ |
| 61 | + | jq '.data["rbac-ui-enabled"] = "false"' \ |
| 62 | + | kubectl replace -f - |
| 63 | +``` |
| 64 | + |
| 65 | +`kubectl patch` fails here: `tigera-network-admin` holds `get` and `update` on this ConfigMap, not `patch`. |
| 66 | + |
| 67 | +### Create a role |
| 68 | + |
| 69 | +1. Click the user icon <IconUser width="20"/> > **Manage Team** > **Roles** > **Create Role**. |
| 70 | +1. If an LDAP directory is connected, **Create Role** opens on a choice between **Bind an IdP group** and **Manual group binding**. Select **Manual group binding** and click **Next** — to bind a directory group instead, see [Bind roles to identity provider groups](#bind-roles-to-identity-provider-groups). With no directory connected, the role form opens straight away. |
| 71 | +1. Enter a **Role Name** and **Description**. The name is the Kubernetes group this role binds to; any non-empty value up to 253 characters is accepted, spaces and `@` included. You attach users and service accounts to it afterwards — see [Give a user a role](#give-a-user-a-role). |
| 72 | +1. Click **Add Permission** and choose one. Permissions are per feature area — policies, network sets, dashboards, service graph, packet captures, egress gateways and so on — each offered as **View** or **Modify**. The picker lists what is available on the cluster. Note that **Alerts and Security Events Settings** covers alert configuration, not the events themselves. |
| 73 | +1. Scope the permission, where it supports it: |
| 74 | + - **Tier** — for policy permissions. Leave it as **all tiers** to apply the permission to every tier. |
| 75 | + - **Namespace** — for namespaced permissions. Leave it as **any namespace** to apply the permission cluster-wide. |
| 76 | +1. Add any further permissions, then click **Save**. A role must carry at least one permission. |
| 77 | + |
| 78 | +To change a role later, select **Actions** > **Edit Permissions**. **Delete Role** removes the role and its bindings from this cluster; subjects bound to it lose the access it granted. |
| 79 | + |
| 80 | +### Give a user a role |
| 81 | + |
| 82 | +Because a role is a group, membership is what grants it. Create the role with [Bind an IdP group](#bind-roles-to-identity-provider-groups) and everyone in that group picks it up at their next sign-in, with nothing to do outside the console. Membership stays managed in your identity provider — see [Configure an external identity provider](configure-identity-provider.mdx). |
| 83 | + |
| 84 | +To audit which group each role binds, list the bindings the console manages. Use the **Users** tab to see who currently holds them. |
| 85 | + |
| 86 | +```bash |
| 87 | +kubectl get clusterrolebinding -l app.kubernetes.io/managed-by=calico-ui-rbac \ |
| 88 | + -o custom-columns='NAME:.metadata.name,ROLE:.roleRef.name,GROUP:.subjects[0].name' |
| 89 | +``` |
| 90 | + |
| 91 | +### Bind roles to identity provider groups |
| 92 | + |
| 93 | +A role can be bound to a group that already exists in your directory, so membership stays managed in your identity provider. Users in that group get the role the next time they sign in. |
| 94 | + |
| 95 | +This requires the cluster to authenticate users with [LDAP](configure-identity-provider.mdx): $[prodname] permits directory-sync traffic only to the host named in `Authentication.spec.ldap.host`, and only on ports 389 and 636. |
| 96 | + |
| 97 | +The directory is read on the management cluster only, so create the secret there and turn role management on there too — even when the role applies to a managed cluster. It is a second secret, separate from the `tigera-ldap-credentials` secret that authentication uses: different namespace, different field names, so copy the values across rather than the keys. |
| 98 | + |
| 99 | +1. Create the directory-sync secret, using the same LDAP host as your `Authentication` resource — as a full URL here, where `Authentication.spec.ldap.host` takes `host:port`. $[prodname] walks the directory with these credentials and offers the groups it finds when you create a role. |
| 100 | + |
| 101 | + ```bash |
| 102 | + kubectl create secret generic tigera-idp-ldap-config -n calico-system \ |
| 103 | + --from-literal=url=ldaps://ad.example.com:636 \ |
| 104 | + --from-literal=bindDN='cn=admin,dc=example,dc=com' \ |
| 105 | + --from-literal=bindPassword='<password>' \ |
| 106 | + --from-literal=baseDN='ou=groups,dc=example,dc=com' |
| 107 | + ``` |
| 108 | + |
| 109 | + Optionally add `groupFilter` (default `(objectClass=groupOfNames)`), `nameAttribute` (default `cn`; Active Directory typically uses `sAMAccountName`), `caBundle` for a private certificate authority, and `refreshIntervalSeconds` (default 300, clamped to 60–86400). |
| 110 | + |
| 111 | +1. Click the user icon <IconUser width="20"/> > **Manage Team** > **Roles** > **Create Role**. |
| 112 | +1. Leave **Bind an IdP group** selected, choose a group from the list, and click **Next**. Groups that already back a role are shown as unavailable. |
| 113 | +1. Add permissions as you would for any role, then click **Save**. The form shows the bound group as a read-only **IdP Group**, alongside a **Role Display Name** you can edit. The display name is a label only, so nothing here has to match your directory. |
| 114 | + |
| 115 | +The role appears in the list with type **Custom - IdP**. Membership is owned by your identity provider, so the role's subjects cannot be edited from the console. A group can back only one role; groups that already have one are marked in the picker. |
| 116 | + |
| 117 | +### See who has access |
| 118 | + |
| 119 | +Click the user icon <IconUser width="20"/> > **Manage Team** > **Users** to review which subjects hold which roles, and when each last signed in. Select a subject to see the permissions its roles carry. |
| 120 | + |
| 121 | +The tab is read-only, and lists the subjects on the roles' bindings plus the members of any bound identity provider groups; **Last signed in** fills in once a subject authenticates. Effective permissions are the union of these roles and anything bound to the subject outside the console, which this view does not show. |
| 122 | + |
| 123 | +### Copy roles to another cluster |
| 124 | + |
| 125 | +Roles apply only to the cluster they were created on. To reuse them elsewhere, export them and apply them to a cluster that also has role management turned on. The export carries each role's bindings, not the permissions they point at, and those exist only where the console has built its catalogue. |
| 126 | + |
| 127 | +1. Select the source cluster, then click the user icon <IconUser width="20"/> > **Manage Team** > **Roles** > **Export YAML**. |
| 128 | +1. Apply the file to each target cluster. |
| 129 | + |
| 130 | + ```bash |
| 131 | + kubectl apply -f <exported-file>.yaml |
| 132 | + ``` |
| 133 | + |
| 134 | +Check first that the target cluster has the tiers and namespaces the roles were scoped to. A binding naming a tier that is missing there applies without error but grants nothing, and a binding into a namespace that does not exist is rejected. |
| 135 | + |
| 136 | +The roles are independent copies: later changes on the source cluster are not propagated. |
| 137 | + |
| 138 | +## Additional resources |
| 139 | + |
| 140 | +- [Configure user roles and permissions](roles-and-permissions.mdx) |
| 141 | +- [Configure an external identity provider](configure-identity-provider.mdx) |
| 142 | +- [Configure RBAC for tiered policies](../../network-policy/policy-tiers/rbac-tiered-policies.mdx) |
0 commit comments