kubernetes 1.20 二进制方式高可用部署之部署Dashboard和CoreDNS(6)

举报
凤凰涅槃 发表于 2022/12/05 12:31:38 2022/12/05
【摘要】 七、部署Dashboard和CoreDNS 7.1 部署Dashboardmaster1节点上面安装Calico时已经下载好了[root@k8s-master1 cfg]# kubectl apply -f kubernetes-dashboard.yaml# 查看部署[root@k8s-master1 cfg]# kubectl get pods,svc -n kubernetes-da...

七、部署Dashboard和CoreDNS

7.1 部署Dashboard

master1节点


上面安装Calico时已经下载好了

[root@k8s-master1 cfg]# kubectl apply -f kubernetes-dashboard.yaml
# 查看部署
[root@k8s-master1 cfg]# kubectl get pods,svc -n kubernetes-dashboard
NAME                                             READY   STATUS              RESTARTS   AGE
pod/dashboard-metrics-scraper-7b59f7d4df-s7c6g   0/1     ContainerCreating   0          27s
pod/kubernetes-dashboard-74d688b6bc-5ln4n        0/1     ContainerCreating   0          27s

NAME                                TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)         AGE
service/dashboard-metrics-scraper   ClusterIP   10.0.0.19    <none>        8000/TCP        27s
service/kubernetes-dashboard        NodePort    10.0.0.9     <none>        443:30001/TCP   27s

发现状态是ContainerCreating,即容器创建中,等待吧…
全部起来大概3分钟左右

#创建service account并绑定默认cluster-admin管理员集群角色
[root@k8s-master1 cfg]# kubectl create serviceaccount dashboard-admin -n kube-system
[root@k8s-master1 cfg]# kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=kube-system:dashboard-admin
[root@k8s-master1 cfg]# kubectl describe secrets -n kube-system $(kubectl -n kube-system get secret | awk '/dashboard-admin/{print $1}')
Name:         dashboard-admin-token-hclxd
Namespace:    kube-system
Labels:       <none>
Annotations:  kubernetes.io/service-account.name: dashboard-admin
              kubernetes.io/service-account.uid: 03acc120-0133-4ccd-8047-9830cff868b3

Type:  kubernetes.io/service-account-token

Data
====
token:      eyJhbGciOiJSUzI1NiIsImtpZCI6InV5ejZ2MlowdnNJaXVTQTJRUW0wTU50Nk01SEdoYVF1N3diMG9oYTRoUkEifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4taGNseGQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiMDNhY2MxMjAtMDEzMy00Y2NkLTgwNDctOTgzMGNmZjg2OGIzIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmRhc2hib2FyZC1hZG1pbiJ9.ON_4fihI9XykB46854v4Lge1AMrKpKvTrhc5Mc1SguroxalskH_hUAtDTBinODOzcz2TP3aJz6uQ5Rq3UWND8i9AcuJl9f9Kpcaml3XnR6sdJSkwNGPvqLxK-uY1pbo-NlOaMs4LjgSJ5_dzLRt4KoLXDF96MSTAenY8E_K_pwfADF67qPUB90rGbyh-jedj9u_F0X4mQf7URYqEDDU1VFMYoVvuD0XdKwdlzRP-_juEXRmdhJoenigr-Y_KwZomWAkIadwK_lKKsSADCXD6uzcTTHZCNnKJFUaClw-oDL214O5CF79Y48nl4ZNqYqUd09X9Rr3qz3PPCrKcY9qHyg
ca.crt:     1359 bytes
namespace:  11 bytes


#访问地址:https://NodeIP:30001

注意一定要加https:// 不然默认就是http,会错哦
随后用上述生成的token访问

7.2 部署CoreDNS

master1节点


上面安装Calico时已经下载好了




#CoreDNS用于集群内部Service名称解析
[root@k8s-master1 cfg]# kubectl apply -f coredns.yaml
[root@k8s-master1 cfg]# kubectl get pods -n kube-system
[root@k8s-master1 cfg]# kubectl get pods -n kube-system
NAME                                      READY   STATUS              RESTARTS   AGE
calico-kube-controllers-97769f7c7-9d49d   1/1     Running             0          60m
calico-node-8djzj                         1/1     Running             0          60m
calico-node-h6ghf                         1/1     Running             0          33m
calico-node-nj9l7                         1/1     Running             0          25m
coredns-6d8f96d957-kzn2g                  0/1     ContainerCreating   0          23s

#DNS解析测试
[root@k8s-master1 cfg]# kubectl run -it --rm dns-test --image=busybox:1.28.4 sh
If you don't see a command prompt, try pressing enter.
/ # nslookup kubernetes
Server:    10.0.0.2
Address 1: 10.0.0.2 kube-dns.kube-system.svc.cluster.local

Name:      kubernetes
Address 1: 10.0.0.1 kubernetes.default.svc.cluster.local

解析没问题。
至此一个单Master集群就搭建完成了!这个环境就足以满足实验了,如果你的服务器配置较高,可继续扩容多Master集群!

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。