重装了k8s集群后,重新安装k8s的仪表板,发现与以前安装不一样的地方。主要是镜像下载的问题,由于网络安全以及国外网站封锁的原因,现在很多镜像按照官方提供的仓库地址都下拉不下来,导致安装失败。我查了好几天,终于找到一个镜像仓库的对照表,并亲自验证,可用(只少目前可用)。下面将对照表和安装文件的修改步骤记录下来,以方便后期同等问题的资料查找。

镜像替换对照表

cr.l5d.io  -->  I5d.m.daocloud.io
docker.elastic.co  -->  elastic.m.daocloud.io
docker.io  -->  docker.m.daocloud.io
gcr.io  -->  gcr.m.daocloudio
ghcr.io  -->  ghcr.m.daocloud.io
k8s.gcr.io  -->  k8s-gcr.m.daocloud.io
registry.k8s.io  -->  k8s.m.daocloud.io
mcr.microsoft.com  -->  mcr.m.daocloud.io
nvcr.io  -->  nvcr.m.daocloud.io
quay.io  -->  quay.m.daocloud.io
registryjujucharms.com  -->  jujucharms.m.daocloud.io
rocks.canonical.com  -->  rocks-canonical.m.daocloud.io

按照官网的安装步骤使用helm安装,先把chart下载下来,我这里使用的是7.0.0版本

部署和访问 Kubernetes 仪表板(Dashboard) | Kubernetes

# 添加 kubernetes-dashboard 仓库
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/

helm pull kubernetes-dashboard/kubernetes-dashboard --version=7.0.0

解压tgz包,修改value.yaml文件

我这里要将pod部署到control-plane节点,所以修改了tolerations值的内容,正常默认pod是部署到work节点的,没有此需求这里不用修改tolerations值的内容

tar -zxvf kubernetes-dashboard-7.0.0.tgz
cd kubernetes-dashboard
vim values.yaml
#image.repository的值,对照上面的镜像替换表,将相应的部分替换就行
比如:
:%s/docker.io/docker.m.daocloud.io/g

#修改容忍污点值和选择节点标签值
:%s/nodeSelector: {}/nodeSelector: {kubernetes-dashboard: master}/g
:%s/tolerations: []/tolerations: [{key: "node-role.kubernetes.io/control-plane", operator: "Exists", effect: "NoSchedule"}]/g

wq

#当然事先要将control-plane节点打上相应标签
kubectl lable nodes k8s70131 kubernetes-dashboard=master


#删除标签命令:kubectl lable nodes k8s70131 kubernetes-dashboard-

在dashboard部署中,官方helm安装是部署了5个不同的pod,

#kubectl get pod -n kubernetes-dashboard
NAME                                                              READY   STATUS    RESTARTS   AGE
kube-dashboard-kong-648bf5ccbc-2fwvm                              1/1     Running   0          40m
kube-dashboard-kubernetes-dashboard-api-7b6758c66b-sh755          1/1     Running   0          40m
kube-dashboard-kubernetes-dashboard-api-7b6758c66b-w9qwp          1/1     Running   0          40m
kube-dashboard-kubernetes-dashboard-api-7b6758c66b-xlbv7          1/1     Running   0          40m
kube-dashboard-kubernetes-dashboard-auth-7c84cb4f66-hkvzs         1/1     Running   0          40m
kube-dashboard-kubernetes-dashboard-metrics-scraper-58bfb6ccvhn   1/1     Running   0          40m
kube-dashboard-kubernetes-dashboard-web-674b665d59-99klb          1/1     Running   0          40m

其中api 的pod是启用的高可用,部署了3个pod。其余的分别部署的是templates/deployments中的api.yaml  auth.yaml  metrics-scraper.yaml  web.yaml 4个yaml文件。但是这里有一个yaml文件也是这四个文件部署中的一个依赖并不在templates目录,而是在chart/kong目录下,可以修改该目录下的values.yaml文件。你也可以通过查找将所有的values.yaml文件都修改了。

#find ./ -name values.yaml
./charts/metrics-server/values.yaml
./charts/ingress-nginx/values.yaml
./charts/kong/charts/postgresql/charts/common/values.yaml
./charts/kong/charts/postgresql/values.yaml
./charts/kong/values.yaml
./charts/cert-manager/values.yaml
./values.yaml


#这里修改的主要是image.repository的值
#在我的需求里还要修改./charts/kong/values.yaml文件中的污点容忍和节点选择标签的值

修改完毕后按照官网的命令执行部署

#在kubernetes-dashboard目录下
helm upgrade --install kubernetes-dashboard ./ --create-namespace --namespace kubernetes-dashboard

#显示如下执行成功kubectl get all -n kubernetes-dashboard
NAME                                                                  READY   STATUS    RESTARTS   AGE
pod/kube-dashboard-kong-648bf5ccbc-2fwvm                              1/1     Running   0          54m
pod/kube-dashboard-kubernetes-dashboard-api-7b6758c66b-sh755          1/1     Running   0          54m
pod/kube-dashboard-kubernetes-dashboard-api-7b6758c66b-w9qwp          1/1     Running   0          54m
pod/kube-dashboard-kubernetes-dashboard-api-7b6758c66b-xlbv7          1/1     Running   0          54m
pod/kube-dashboard-kubernetes-dashboard-auth-7c84cb4f66-hkvzs         1/1     Running   0          54m
pod/kube-dashboard-kubernetes-dashboard-metrics-scraper-58bfb6ccvhn   1/1     Running   0          54m
pod/kube-dashboard-kubernetes-dashboard-web-674b665d59-99klb          1/1     Running   0          54m

NAME                                                          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                         AGE
service/kube-dashboard-kong-manager                           NodePort    22.96.57.8      <none>        8002:32446/TCP,8445:30155/TCP   54m
service/kube-dashboard-kong-proxy                             ClusterIP   22.106.141.34   <none>        443/TCP                         54m
service/kube-dashboard-kubernetes-dashboard-api               ClusterIP   22.103.124.54   <none>        8000/TCP                        54m
service/kube-dashboard-kubernetes-dashboard-auth              ClusterIP   22.98.132.104   <none>        8000/TCP                        54m
service/kube-dashboard-kubernetes-dashboard-metrics-scraper   ClusterIP   22.101.13.33    <none>        8000/TCP                        54m
service/kube-dashboard-kubernetes-dashboard-web               ClusterIP   22.102.248.97   <none>        8000/TCP                        54m

NAME                                                                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/kube-dashboard-kong                                   1/1     1            1           54m
deployment.apps/kube-dashboard-kubernetes-dashboard-api               3/3     3            3           54m
deployment.apps/kube-dashboard-kubernetes-dashboard-auth              1/1     1            1           54m
deployment.apps/kube-dashboard-kubernetes-dashboard-metrics-scraper   1/1     1            1           54m
deployment.apps/kube-dashboard-kubernetes-dashboard-web               1/1     1            1           54m

NAME                                                                             DESIRED   CURRENT   READY   AGE
replicaset.apps/kube-dashboard-kong-648bf5ccbc                                   1         1         1       54m
replicaset.apps/kube-dashboard-kubernetes-dashboard-api-7b6758c66b               3         3         3       54m
replicaset.apps/kube-dashboard-kubernetes-dashboard-auth-7c84cb4f66              1         1         1       54m
replicaset.apps/kube-dashboard-kubernetes-dashboard-metrics-scraper-58bfb68c56   1         1         1       54m
replicaset.apps/kube-dashboard-kubernetes-dashboard-web-674b665d59               1         1         1       54m

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐