Skip to content

Latest commit

 

History

History
64 lines (50 loc) · 1.19 KB

RBAC.MD

File metadata and controls

64 lines (50 loc) · 1.19 KB

Each role has 3 sections

  • apiGroups
  • resources
  • verbs

create the role with kubectl command

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: developer
rules:
- apiGroups: [""] # "" indicates the core API group
  resources: ["pods"]
  verbs: ["get", "list", "update", "delete", "create"]
- apiGroups: [""]
  resources: ["ConfigMap"]
  verbs: ["create"]

Bind the Role

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: devuser-developer-binding
subjects:
- kind: User
  name: dev-user # "name" is case sensitive
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: developer
  apiGroup: rbac.authorization.k8s.io
  • list roles

kubectl get roles

  • To list rolebindings

kubectl get rolebindings

  • To describe role

kubectl describe role developer

  • describe rolebinging

kubectl describe rolebinding devuser-developer-binding

check access

You can use the kubectl auth command

kubectl auth can-i create deployments
kubectl auth can-i delete nodes
kubectl auth can-i create deployments --as dev-user
kubectl auth can-i create pods --as dev-user
kubectl auth can-i create pods --as dev-user --namespace test