共计 1993 个字符,预计需要花费 5 分钟才能阅读完成。
下载
先从官网把部署 Kubernetes Dashboard 的 yaml 下载到本地。
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
PS:如果因为墙了,本人想方法,总之先下载下来。
部署
执行上面的命令进行 Kubernetes Dashboard 部署
kubectl apply -f ./recommended.yaml
执行之后输入以下信息,示意曾经部署胜利
namespace/kubernetes-dashboard created
serviceaccount/kubernetes-dashboard created
service/kubernetes-dashboard created
secret/kubernetes-dashboard-certs created
secret/kubernetes-dashboard-csrf created
secret/kubernetes-dashboard-key-holder created
configmap/kubernetes-dashboard-settings created
role.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
deployment.apps/kubernetes-dashboard created
service/dashboard-metrics-scraper created
deployment.apps/dashboard-metrics-scraper created
查问一下 pod 和 service 是否都曾经创立
- 查问 kubernetes-dashboard 命名空间下全副 pod
kubectl get pods -n kubernetes-dashboard
NAME READY STATUS RESTARTS AGE
dashboard-metrics-scraper-64bcc67c9c-6hbv5 1/1 Running 0 4m
kubernetes-dashboard-5c8bd6b59-mm7gh 1/1 Running 0 4m
- 查问 kubernetes-dashboard 命名空间下全副 service
kubectl get svc -n kubernetes-dashboard
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
dashboard-metrics-scraper ClusterIP 10.102.13.19 <none> 8000/TCP 4m22s
kubernetes-dashboard ClusterIP 10.109.154.224 <none> 443:/TCP 4m22s
能够看到 service 的 TYPE 是 ClusterIP
:只对集群外部可见,内部无法访问。NodePort
:才可对外部可见。
因而然而 443 端口仍是外部才能够拜访的,咱们机器无法访问,因而须要将 443 端口映射进去。
映射端口让内部能够拜访
执行一下命令,即可随机调配一个 30000+ 的端口映射 443 即 https 端口
kubectl patch svc kubernetes-dashboard -p '{"spec":{"type":"NodePort"}}' -n kubernetes-dashboard
执行后,咱们再执行kubectl get svc -n kubernetes-dashboard
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
dashboard-metrics-scraper ClusterIP 10.102.13.19 <none> 8000/TCP 4m22s
kubernetes-dashboard NodePort 10.109.154.224 <none> 443:31767/TCP 4m22s
曾经将 kubernetes-dashboard 的 service TYPE 改为了 NodePort,内部端口是 31767。
实现
浏览器关上:https://localhost:31767/
如果 Chrome/Edge 提醒不平安,你就在页面出,盲敲 thisisunsafe
,就能够进入。
到此为止就能够进入 kubernetes-dashboard。
正文完
发表至: kubernetes
2023-03-01