Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Let's find out now how to create a new user using the Kubernetes service account mechanism, which grants the created user the administrator permissions and access to the Dashboard, using the associated bearer token. We create the dashboard-adminuser.yaml file, which we will then launch with the command

$ kubectl apply -f
Code Block
Account
languagebashyml
title
dashboard-adminuser.yaml

The contents of the file are as follows

No Format
apiVersion: v1
kind: ServiceAccount
metadata: 
  name: admin-user
  namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kubernetes-dashboard

which we will then launch with the command kubectl apply -f dashboard-adminuser.yaml. Finally, we obtain the token (present in the last line), which will be pasted on the Dashboard login screen, by launching the command

...