Deploy Kubernetes Dashboard to Cluster on Ubuntu 22.04

,

หลังจากที่เราลอง Install Kubernetes กันไปแล้ว เราจะมาลอง Deploy Kubernetes Dashboard ซึ่งเป็น web-based เพื่อเอาไว้สำหรับ Monitor ซึ่งขั้นตอนการ Deploy ก็ไม่ยาก แต่ต้องติดตั้ง Helm Package กันก่อน

Requirement

Get Started

  • ทำการติดตั้ง Helm Package
# curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null
# sudo apt-get install apt-transport-https --yes
# echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
# sudo apt-get update
# sudo apt-get install helm
  • ทำการ Add Repo
# helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
  • ทำการ Deploy
# helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard
Release "kubernetes-dashboard" does not exist. Installing it now.
NAME: kubernetes-dashboard
LAST DEPLOYED: Wed Jun  5 11:20:47 2024
NAMESPACE: kubernetes-dashboard
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
*************************************************************************************************
*** PLEASE BE PATIENT: Kubernetes Dashboard may need a few minutes to get up and become ready ***
*************************************************************************************************

Congratulations! You have just installed Kubernetes Dashboard in your cluster.

To access Dashboard run:
  kubectl -n kubernetes-dashboard port-forward svc/kubernetes-dashboard-kong-proxy 8443:443

NOTE: In case port-forward command does not work, make sure that kong service name is correct.
      Check the services in Kubernetes Dashboard namespace using:
        kubectl -n kubernetes-dashboard get svc

Dashboard will be available at:
  https://localhost:8443
  • ทำการตรวจสอบ Service
# kubectl -n kubernetes-dashboard get svc
NAME                                   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                         AGE
kubernetes-dashboard-api               ClusterIP   10.103.95.240    <none>        8000/TCP                        4m51s
kubernetes-dashboard-auth              ClusterIP   10.102.127.80    <none>        8000/TCP                        4m51s
kubernetes-dashboard-kong-manager      NodePort    10.107.104.49    <none>        8002:32396/TCP,8445:31888/TCP   4m51s
kubernetes-dashboard-kong-proxy        ClusterIP   10.104.210.58    <none>        443/TCP                         4m51s
kubernetes-dashboard-metrics-scraper   ClusterIP   10.104.202.227   <none>        8000/TCP                        4m51s
kubernetes-dashboard-web               ClusterIP   10.111.103.3     <none>        8000/TCP                        4m51s
  • ทำการสร้างไฟล์ 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
  • ทำการ Create Admin User
# kubectl apply -f dashboard-adminuser.yaml
  • ทำการ Create Token
# kubectl -n kubernetes-dashboard create token admin-user
eyJhbGciOiJSUzI1NiIsImtpZCI6ImJ6anVLbDNQcTlETjVHNl9Mbk1BdzVNdEMyN25tZEE0dDZZOGZHUGpkWDgifQ.eyJhdWQiOlsiaHR0cHM6Ly9rdWJlcm5ldGVzLmRlZmF1bHQuc3ZjLmNsdXN0ZXIubG9jYWwiXSwiZXhwIjoxNzE3NTY1NTAyLCJpYXQiOjE3MTc1NjE5MDIsImlzcyI6Imh0dHBzOi8va3ViZXJuZXRlcy5kZWZhdWx0LnN2Yy5jbHVzdGVyLmxvY2FsIiwia3ViZXJuZXRlcy5pbyI6eyJuYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsInNlcnZpY2VhY2NvdW50Ijp7Im5hbWUiOiJhZG1pbi11c2VyIiwidWlkIjoiYTU3ZmQzOWUtZTk1NC00MGZkLWFiYTEtM2E0MTU1NDNiNWMzIn19LCJuYmYiOjE3MTc1NjE5MDIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlcm5ldGVzLWRhc2hib2FyZDphZG1pbi11c2VyIn0.xmvrONcU4TZPd94v_QDrdO8wRd9SD90JzWaXW37EJLQa5Pq6akQinZaqV0wFTSk-YHGoXgNADJodwdYaCROvVXErevkOQTiPkeo6AddznSe2vC_OWuylJunxvENF59H5iUAKtfnXgXPOOXuaTYVR1m1VO1nW6Yh_gsE5Y9zZhQ1VyQqpSWKvH1Az-qtCi8LCAucVVtrIFU9EdB24Ibf3xi8DgR42FPyfb4HSn3Of-iJHCZ6dPkWEcWdLhFJX-UVil7DDpFax0ulMSPj-6aqfk2HfsIOyajhtwSSH8xOcAWI3-we7qwl3y9SwgYOvCUdIuu9he_b2a1AhSBUSjZrD1w
  • ทำการ Access Dashboard
# kubectl -n kubernetes-dashboard port-forward svc/kubernetes-dashboard-kong-proxy 8443:443
Forwarding from 127.0.0.1:8443 -> 8443
Forwarding from [::1]:8443 -> 8443
  • หลังจาก Login เข้ามาจะเห็นหน้าตาแบบนี้

อ่านเพิ่มเติม : https://bit.ly/3Kv4TxG


Leave a Reply

Your email address will not be published. Required fields are marked *