Introduction
Kubernetes Dashboard is a web-based Kubernetes User Interface. You can use the Dashboard to deploy manifest files to Kubernetes and manage cluster resources. Let’s see how to configure the Kubernetes Dashboard.
I refer to the following Document.
Dashboard Install
Namespace confirmation
[root@centos7 vagrant]# $ kubectl get ns -o wide
NAME STATUS AGE
default Active 11h
kube-node-lease Active 11h
kube-public Active 11h
kube-system Active 11h
Deploy the Kubernetes Dashboard. namespace: kubernetes-dashboard is created and the necessary items such as Service Cluster IP are configured.
[root@centos7 vagrant]# kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta8/aio/deploy/recommended.yaml
Confirm Namespace. kubernetes-dashboard has been created.
[root@centos7 vagrant]# kubectl get ns -o wide
NAME STATUS AGE
default Active 11h
kube-node-lease Active 11h
kube-public Active 11h
kube-system Active 11h
kubernetes-dashboard Active 10s
Create the required user (ServiceAccount) for the Kubernetes Dashboard. In this step, you will create a user with cluster-admin privileges.
⚠️ It has a fairly high authority. May be a security risk to apply in a commercial environment.
[root@centos7 vagrant]# cat << 'EOF' > ~/workdir/kubernetes-dashboard-admin-user.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
EOF
apply this yaml
[root@centos7 vagrant]# kubectl apply -f ~/workdir/kubernetes-dashboard-admin-user.yaml
Get a Token to access the Kubernetes Dashboard.
[root@centos7 vagrant]# kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')
Execution example, Let’s copy the token at the bottom.
[root@centos7 vagrant]# kubectl -n kubernetes-dashboard describe secret $ (kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $ 1}')
Name: admin-user-token-x69v9
Namespace: kubernetes-dashboard
Labels: <none>
Annotations: kubernetes.io/service-account.name: admin-user
kubernetes.io/service-account.uid: 5a5a889e-f4d4-11ea-adc1-0242ac120002
Type: kubernetes.io/service-account-token
Data
====
ca.crt: 1289 bytes
namespace: 20 bytes
token: Token is displayed here
From kubectl installed on your computer, run the following command: This will proxy localhost access to external Kubernetes.
[root@centos7 vagrant]# kubectl proxy
Run the following URL to open the login screen.
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login
You should see a window in which we will be able to paste our token.
Metrics Server Install
I was able to access the Kubernetes Dashboard. You can check Deployment and its subordinate pods on the Web. However, at this stage, the CPU usage and memory of the pod are not displayed. You must have Kubernetes Metrics Server installed to see this metrics.
Install Metrics Server. Created under the namespace kube-system
[root@centos7 vagrant]# kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.3.6/components.yaml
As a result of deploying Metrics Server, resource utilization is now retrieved and displayed.