Skip to main content

📋 Roles

A Role is a list of what is allowed to be done within a namespace. Example: "can read pods, but cannot delete". It defines the permissions, but does not hand them to anyone. That is done by RBAC (next page).

TypeApplies toWhen to use
RoleOne namespaceMost cases
ClusterRoleThe entire clusterResources without a namespace (such as nodes) or permissions across all namespaces

Each rule combines what (resources, such as pods and services) with what to do (verbs):

VerbMeaning
get, list, watchRead
createCreate
update, patchModify
deleteDelete
info

Roles are created with kubectl. The Nuvion Panel does not have a screen for this feature.


🚀 Before you start​

  • Have cluster access configured.

🚀 1. See the permissions that already exist​

kubectl get roles -A
kubectl get clusterrole view edit admin cluster-admin

The ClusterRoles view, edit, admin and cluster-admin come ready-made:

ClusterRoleWhat it allows
viewRead-only
editRead and modify most resources
adminFull control within a namespace
cluster-adminFull control of the entire cluster

🚀 2. Create a pod-reading Role​

kubectl create role leitor-pods --verb=get,list,watch --resource=pods

Expected output: role.rbac.authorization.k8s.io/leitor-pods created

🚀 3. See the details​

kubectl describe role leitor-pods

The table shows the resource (pods) and the allowed verbs (get, list, watch).

🚀 4. Understand the Role in YAML​

The command from step 2 is equivalent to this file:

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: leitor-pods
namespace: default
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]

apiGroups: [""] (empty) indicates the core Kubernetes group, where pods, services, configmaps and secrets live.

🚀 5. Create a ClusterRole​

Nodes do not belong to any namespace, so they need a ClusterRole:

kubectl create clusterrole leitor-nodes --verb=get,list,watch --resource=nodes

✅ How to know it worked​

kubectl get role leitor-pods
kubectl get clusterrole leitor-nodes

Both appear in the list.

🔒 Best practices​

  • Grant only what is needed (least privilege).
  • Avoid * in verbs and resources.
  • Be even stricter with secrets, since allowing read is equivalent to handing out passwords.

❗ Common problems​

SymptomCauseSolution
forbidden: ... cannot create resource "roles"Your user cannot create RolesAsk a cluster administrator
Error mentioning escalation or attempting to grant RBAC permissions not currently heldKubernetes does not let you create a Role with permissions greater than your ownUse a user with more permissions
already existsName already in useUse another name or delete the existing Role

🧹 Cleanup​

Only clean up after completing the RBAC page, which uses the leitor-pods Role:

kubectl delete role leitor-pods
kubectl delete clusterrole leitor-nodes

➡️ Next step: RBAC

🧠 Questions?​

Talk to our SaveinCloud technical support team!