简体   繁体   中英

How to grant access to specify namespace in kubernetes dashboard?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM