Kubernetes dashboard is a web ui console, Users can manage/view applications which is running in Kubernetes cluster and troubleshoot them.
Requirements,
Kubernetes cluster
Step 1:
Install kubernetes dashboard,
# kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.3/aio/deploy/recommended.yaml
Using the latest version.
check the pods status for kubernetes dashboard.
# kubectl get pods -n kubernetes-dashboard
Step 2:
Kubernetes dashboard access,
Make the dashboard accessible outside by changing the network type to NodePort
# kubectl get svc -n kubernetes-dashboard
# kubetcl edit svc kubernetes-dashboard -n kubernetes-dashboard
Now got the port number to access the kubernetes dashboard.
URL : https://kubernetes-IP:PortNo.
eg : https://192.168.108.6:30778
Step 4:
Token Generation,
Create cluster admin service account:
To login kubrnetes dashboard we need to create a service account by using below commands to create it and get the token.
# kubectl create serviceaccount admin-user
# kubectl create clusterrolebinding admin-user --clusterrole=cluster-admin --serviceaccount=default:admin-user
Next, get the token.
# kubectl get secret|grep admin-user
# kubectl describe secret admin-user-token-hglv9
Now copy token from the second command and enter in the Kubernetes dashboard by choosing token.
To create a limited access service account will allow to access only pods.
# vi pod-access.yaml
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: pod-access
rules:
- apiGroups: [""] # core API group
resources: ["pods", "namespaces"]
verbs: ["get", "watch", "list"]
save and close the file.
# kubectl create serviceaccount pod-access
# kubectl apply -f pod-access.yaml
# kubectl create clusterrolebinding pod-access --clusterrole=pod-access --serviceaccount=default:pod-access
# kubectl get secret
# kubectl describe secret pod-access-token-kx2jc
Now use this token in kubernetes dashboard which will has access to only pods.
That's all, Kubernetes dashboard has been installed successfully and created admin and limited access service accounts to login dashboard.
Post a Comment