Skip to content

Instantly share code, notes, and snippets.

@finesse-fingers
Last active August 8, 2021 02:42
Show Gist options
  • Save finesse-fingers/11c983108972a00776fe4243e01d87df to your computer and use it in GitHub Desktop.
Save finesse-fingers/11c983108972a00776fe4243e01d87df to your computer and use it in GitHub Desktop.

Setting up K8 Web UI Dashboard

kubectl Installation

Metric server install:

https://github.com/kubernetes-sigs/metrics-server

kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml

Web UI (Dashboard install):

https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/

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

Create a user:

https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md

# dashboard-adminuser.yaml
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

Apply the manifest:

kubectl apply -f dashboard-adminuser.yaml

Dashboard Auth token:

Get the token

kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}") -o go-template="{{.data.token | base64decode}}"

To access dashboard:

kubectl proxy

Go to: http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

Copy and paste the token from above. Done!

Alternative Helm Chart Installation

https://github.com/kubernetes/dashboard/tree/master/aio/deploy/helm-chart/kubernetes-dashboard

helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
helm install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --namespace k8-dashboard --create-namespace

Get auth token by running:

kubectl describe secret -n k8-dashboard

To access dashboard:

kubectl proxy

Access UI here: http://localhost:8001/api/v1/namespaces/k8-dashboard/services/https:kubernetes-dashboard:https/proxy/

To clean up run:

helm uninstall kubernetes-dashboard -n k8-dashboard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment