I have multiple namespace in my k8s cluster and user too. I deployed K8S dashboard, and now I want to grant access to namespace to specify user. EX: user A only access namespace A on dashboard user B is only access namespace B on dashboard.
Could anyone give some snippet config?
Thanks all.
Create a role and role binding as below and add the user to the specific group
(This is just an example config and you may not want to give your user full access to namespace)
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: example-ns-full-access
namespace: example-ns
rules:
- apiGroups: [""]
resources: ["*"]
verbs: ["*"]
- apiGroups: ["extensions"]
resources: ["*"]
verbs: ["*"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: example-rolebinding
namespace: example-ns
subjects:
- kind: Group
name: example-admins
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: Role
name: example-ns-full-access
apiGroup: rbac.authorization.k8s.io