tonglin0325的个人主页

helm部署kubernetes-dashboard

kuberbetes-dashboard是K8S的管理工具,下面使用helm来进行部署,参考:

1
2
https://artifacthub.io/packages/helm/k8s-dashboard/kubernetes-dashboard

首先添加源#

1
2
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/

查找chart#

1
2
3
4
5
helm search repo kubernetes-dashboard

NAME CHART VERSION APP VERSION DESCRIPTION
kubernetes-dashboard/kubernetes-dashboard 5.4.1 2.5.1 General-purpose web UI for Kubernetes clusters

部署release#

1
2
helm install my-k8s-dashboard kubernetes-dashboard/kubernetes-dashboard

访问kubernetes dashboard#

1.修改kubernetes-dashboard的svc,将ClusterIp改成NodePort#

 

此时再查看svc

1
2
3
4
kubectl get svc -A
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default my-k8s-dashboard-kubernetes-dashboard NodePort 10.110.255.104 <none> 443:32511/TCP 21h

访问如下网址即可,注意这里建议使用firefox浏览器来访问,提示HTTPS不安全的话可以选择忽略;如果使用chrome浏览器的话,会提示需要需要导入HTTPS证书,证书地址如下

1
/etc/kubernetes/pki/ca.crt  

 

2.也使用kubectl proxy来访问#

参考

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

设置proxy,address是你的运行minikube或者docker-desktop的机器ip,port是对外暴露的端口

1
2
kubectl proxy --address='localhost' --port=18000

查看kubernetes-dashboard的svc

1
2
3
4
5
kubectl get svc -A
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE

default my-k8s-dashboard-kubernetes-dashboard ClusterIP 10.110.255.104 <none> 443/TCP 87m

接下来在浏览器里面输入如下地址就可以访问kubernetes-dashboard了

localhost是运行minikube或者docker-desktop的机器ip,18000就是kubectl proxy里面的address,default是kubernetes-dashboard部署的namespace,my-k8s-dashboard-kubernetes-dashboard:443是部署的service的name的port

1
2
http://localhost:18000/api/v1/namespaces/default/services/https:my-k8s-dashboard-kubernetes-dashboard:443/proxy/#/login

这时候部署的dashboard是HTTPS的

3.在局域网访问kubernetes-dashboard#