Role in Kubernetes

Using roles in Kubernetes

Planted .

Type of object defined by RBAC API.

A Role or ClusterRole contains rules that represent a set of permissions. Permissions are additive, there are no denies.

A Role sets permissions in a specific namespace.

ClusterRole is non-namespace specific.

Example role

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: default
  name: pod-reader
rules:
- apiGroups: [""] # "" indicates the core API group
  resources: ["pods"]
  verbs: ["get", "watch", "list"]

Example cluster role

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  # "namespace" omitted since ClusterRoles are not namespaced
  name: secret-reader
rules:
- apiGroups: [""]
  #
  # at the HTTP level, the name of the resource for accessing Secret
  # objects is "secrets"
  resources: ["secrets"]
  verbs: ["get", "watch", "list"]
Updated . Thoughts? Email me.