内容目录
- 安装过程:Windows平台下使用Docker安装Kubernetes(K8S) Dashboard搭建和部署
使用 kubectl proxy 启用 Dashboard时访问http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/网址报错,报错内容如下:
{ "kind": "Status", "apiVersion": "v1", "metadata": {}, "status": "Failure", "message": "no endpoints available for service \"https:kubernetes-dashboard:\"", "reason": "ServiceUnavailable", "code": 503 }
执行命令
kubectl get pod -n kubernetes-dashboard
,获取指定名称空间的podD:\k8s-for-docker-desktop-1.25.0>kubectl get pod -n kubernetes-dashboard NAME READY STATUS RESTARTS AGE dashboard-metrics-scraper-748b4f5b9d-5spjg 1/1 Running 0 41m kubernetes-dashboard-68955f84f4-lmqbs 0/1 ImagePullBackOff 0 41m
查看结果会发现kubernetes-dashboard 名称空间下的 Pod kubernetes-dashboard-68955f84f4-lmqbs 状态出现ImagePullBackOff
执行命令
kubectl describe pod kubernetes-dashboard-68955f84f4-lmqbs
,查看pod 节点的描述信息D:\k8s-for-docker-desktop-1.25.0>kubectl describe pod kubernetes-dashboard-68955f84f4-lmqbs Error from server (NotFound): pods "kubernetes-dashboard-68955f84f4-lmqbs" not found
执行命令
kubectl get pods kubernetes-dashboard-68955f84f4-lmqbs -n kubernetes-dashboard -o wide
,获取kubernetes-dashboard的pod信息,并查看附加信息【如:pod的IP及在哪个节点NODE运行等】D:\k8s-for-docker-desktop-1.25.0>kubectl get pods kubernetes-dashboard-68955f84f4-lmqbs -n kubernetes-dashboard -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES kubernetes-dashboard-68955f84f4-lmqbs 0/1 ImagePullBackOff 0 49m 10.1.0.32 docker-desktop <none> <none>
从结果中查看NODE参数能看到该Pod被调度到了 docker-desktop节点
执行命令
kubectl get pods kubernetes-dashboard-68955f84f4-lmqbs -n kubernetes-dashboard -o yaml
,确定Pod所使用的容器镜像:D:\k8s-for-docker-desktop-1.25.0>kubectl get pods kubernetes-dashboard-68955f84f4-lmqbs -n kubernetes-dashboard -o yaml apiVersion: v1 kind: Pod metadata: creationTimestamp: "2022-12-15T05:46:49Z" generateName: kubernetes-dashboard-68955f84f4- labels: k8s-app: kubernetes-dashboard pod-template-hash: 68955f84f4 name: kubernetes-dashboard-68955f84f4-lmqbs namespace: kubernetes-dashboard ownerReferences: - apiVersion: apps/v1 blockOwnerDeletion: true controller: true kind: ReplicaSet name: kubernetes-dashboard-68955f84f4 uid: a5439d01-3fb9-44bc-888b-cb07b8d43c60 resourceVersion: "5801" uid: e76f43bb-c2f8-4f9f-ae5c-568d876bd284 spec: containers: - args: - --auto-generate-certificates - --namespace=kubernetes-dashboard image: kubernetesui/dashboard:v2.5.1 imagePullPolicy: IfNotPresent
从结果中查看image参数参数能看到该Pod使用到了容器镜像是
kubernetesui/dashboard:v2.5.1
- 然后使用Docker拉取对应的容器镜像,
docker pull kubernetesui/dashboard:v2.5.1
,然后耐心等待结果 - 镜像拉取成功后,重新运行
kubectl proxy
- 命令行窗口不关闭的情况下打开浏览器访问网址:http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
运行结果是下面这样的则表示问题已解决
0 条评论
撰写评论