kubernetes Dashboard

by Anish

Posted on Thursday July 12, 2018



This sample chapter extracted from the book, Kubernetes for DevOps .

Get this book on Just $9 or Ask Author for Discount

Dashboard is a web-based Kubernetes user interface. You can use Dashboard to deploy containerized applications to a Kubernetes cluster, troubleshoot your containerized application, and manage the cluster itself along with its attendant resources. These are the required steps to to bring up the kubernetes Dashboard

If you have a $HOME/.kube/config file, and it's not listed in your KUBECONFIG environment variable, then do the following.

export KUBECONFIG=/etc/kubernetes/admin.conf

Deploy Kubernetes Dashboard

To deploy run the following command:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml

The output

secret/kubernetes-dashboard-certs created
serviceaccount/kubernetes-dashboard created
role.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
deployment.apps/kubernetes-dashboard created
service/kubernetes-dashboard created

Once the Dashboard is created verify the svc/deployments are up and running

Verify Dashboard Service is running

kubectl get services -n kube-system
NAME                   TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)         AGE
kube-dns               ClusterIP     <none>        53/UDP,53/TCP   1m
kubernetes-dashboard   ClusterIP   <none>        443/TCP         8s

Describe the Kubernetes Dashboard

RUn the following command to view the svc info

kubectl describe svc/kubernetes-dashboard -n kube-system

Verify the kubernetes-dashboard pods is up and running

kubectl get pods --all-namespaces
NAMESPACE     NAME                                   READY     STATUS    RESTARTS   AGE
kube-system   kubernetes-dashboard-6948bdb78-76686   1/1       Running   0          7m

You can grant full admin privileges to Dashboard's Service Account by creating below ClusterRoleBinding. Copy the YAML file based on chosen installation method and save as, i.e. dashboard-admin.yaml. Use

kubectl create -f dashboard-admin.yaml

to deploy it . Afterwards you can use Skip option on login page to access Dashboard.

cat dashboard-admin.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
  name: kubernetes-dashboard
    k8s-app: kubernetes-dashboard
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
- kind: ServiceAccount
  name: kubernetes-dashboard
  namespace: kube-system
root@kube-master:/home/ansible# kubectl create -f dashboard-admin.yaml
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created

The Dashboard UI View

Using Skip option will make Dashboard use privileges of Service Account used by Dashboard.


Kubernetes Dashbaord Access

Set the proxy

kubectl proxy --address --accept-hosts '.*'

Starting to serve on [::]:8001

Access the Kubernetes dashboard


Kubernetes Dashbaord Authentication using Token

Create a new ServiceAccount

kubectl create serviceaccount k8sadmin -n kube-system
serviceaccount/k8sadmin created

Create a ClusterRoleBinding with Cluster Admin Privileges

kubectl create clusterrolebinding k8sadmin --clusterrole=cluster-admin --serviceaccount=kube-system:k8sadmin
clusterrolebinding.rbac.authorization.k8s.io/k8sadmin created

Get the token

kubectl get secret -n kube-system | grep k8sadmin | cut -d " " -f1 | xargs -n 1 | xargs kubectl get secret  -o 'jsonpath={.data.token}' -n kube-system | base64 --decode
The outout will be base64 decoded Token eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9

Use this token to login to kubernetes dashbaord

Referefce Referefce

Delete Kubernetes dashboard Servcie

check from where the service needs to be deleted daemonsets,replicasets,services,deployments,pods,rc --all

kubectl delete replicasets/kubernetes-dashboard -n kube-system
kubectl delete svc/kubernetes-dashboard -n kube-system
kubectl delete deployments/kubernetes-dashboard -n kube-system
kubectl -n kube-system delete $(kubectl -n kube-system get pod -o name | grep dashboard)

Edit Kubernetes dashboard Service

kubectl edit svc/kubernetes-dashboard -n kube-system

Video Demo

Thanku for reading !!! Give a Share for Support

Asking for donation sound bad to me, so i'm raising fund from by offering all my Nine book for just $9

python Cryptography Topics
For Coffee/ Beer/ Amazon Bill and further development of the project Support by Purchasing, The Modern Cryptography CookBook for Just $9 Coupon Price

Kubernetes for DevOps

Hello Dockerfile

Cryptography for Python Developers

Cryptography for JavaScript Developers

Go lang ryptography for Developers