k8s多节点仪表盘(web界面)部署与谷歌浏览器访问k8s仪表盘问题解决!
文章目录k8s的WEB界面部署两个master节点检查pod资源是否正常master节点上创建dashboard工作目录,并拷贝部署web界面所需的文件到指定目录创建资源(顺序不可以乱)谷歌浏览器无法访问的问题解决生成令牌选择使用令牌访问k8s的WEB界面部署两个master节点检查pod资源是否正常[root@localhost ~]# kubectl get nodes'//检查node节点是
·
文章目录
k8s的WEB界面部署
两个master节点检查pod资源是否正常
[root@localhost ~]# kubectl get nodes '//检查node节点是否运行正常'
NAME STATUS ROLES AGE VERSION
192.168.136.30 Ready <none> 15h v1.12.3
192.168.136.40 Ready <none> 15h v1.12.3
[root@master ~]# kubectl get pods '//检查之前创建的pod资源是否运行正常'
NAME READY STATUS RESTARTS AGE
nginx-dbddb74b8-5s6h7 1/1 Running 0 7d8h
master节点上创建dashboard工作目录,并拷贝部署web界面所需的文件到指定目录
- 下载的网址(直接复制即可):https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/dashboard
在master01上操作
创建dashborad工作目录
[root@localhost k8s]# mkdir dashboard
[root@localhost k8s]# cd /root/k8s/dashboard/
[root@localhost dashboard]# ls
dashboard-configmap.yaml dashboard-rbac.yaml dashboard-service.yaml
dashboard-controller.yaml dashboard-secret.yaml k8s-admin.yaml
configmap.yaml:配置,deployment.yaml:控制器,rbac.yaml:角色控制,访问控制,secret.yaml:安全,service.yaml:服务’
我们查看一下里面的内容
[root@localhost dashboard]# vim dashboard-rbac.yaml
创建资源(顺序不可以乱)
1:创建rbac.yaml:角色控制
[root@localhost dashboard]# kubectl create -f dashboard-rbac.yaml
2:创建secret.yaml:安全
[root@localhost dashboard]# kubectl create -f dashboard-secret.yaml
3:创建configmap.yaml:配置
[root@localhost dashboard]# kubectl create -f dashboard-configmap.yaml
4:创建controller
[root@localhost dashboard]# kubectl create -f dashboard-controller.yaml
5:创建service
[root@localhost dashboard]# kubectl create -f dashboard-service.yaml
查看资源是否被创建
[root@localhost dashboard]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
kubernetes-dashboard-7dffbccd68-jmbgg 1/1 Running 1 10h
查看所有创建的资源
[root@localhost dashboard]# kubectl get role -n kube-system
[root@localhost dashboard]# kubectl get Secret -n kube-system
[root@localhost dashboard]# kubectl get ConfigMap -n kube-system
[root@localhost dashboard]# kubectl get ServiceAccount -n kube-system
[root@localhost dashboard]# kubectl get Service -n kube-system
查看server资源和pods资源
kubectl get pods,svc -n kube-system
查看地址
kubectl get pods -n kube-system -o wide(查看pod资源)
kubernetes-dashboard-7dffbccd68-jmbgg 1/1 Running 1 10h 172.17.38.2 192.168.136.40 <none>
访问https://192.168.136.40:300001这里是无法访问的
谷歌浏览器无法访问的问题解决
建立签名证书
[root@localhost dashboard]# vim dashboard-cert.sh
cat > dashboard-csr.json <<EOF
{
"CN": "Dashboard",
"hosts": [],
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "CN",
"L": "BeiJing",
"ST": "BeiJing"
}
]
}
EOF
K8S_CA=$1
cfssl gencert -ca=$K8S_CA/ca.pem -ca-key=$K8S_CA/ca-key.pem -config=$K8S_CA/ca-config.json -profile=kubernetes dashboard-csr.json | cfssljson -bare dashboard
创建证书
先删除资源
kubectl delete secret kubernetes-dashboard-certs -n kube-system
创建证书
kubectl create secret generic kubernetes-dashboard-certs --from-file=./ -n kube-system
执行指令
bash dashboard-cert.sh /root/k8s/k8s-cert/
自签证书
[root@localhost dashboard]# vim dashboard-controller.yaml
47 - --auto-generate-certificates 下面添加
48 - --tls-key-file=dashboard-key.pem
49 - --tls-cert-file=dashboard.pem
重新部署
kubectl apply -f dashboard-controller.yaml
如果上面命令无法操作请尝试下面
kubectl delete -f dashboard-controller.yaml
kubectl create -f dashboard-controller.yaml
在次访问出现点击继续访问
生成令牌
[root@localhost dashboard]# kubectl create -f k8s-admin.yaml
保存
[root@localhost dashboard]# kubectl get secret -n kube-system
NAME TYPE DATA AGE
dashboard-admin-token-gxfmr kubernetes.io/service-account-token 3 34s
default-token-zpjbp kubernetes.io/service-account-token 3 6h9m
kubernetes-dashboard-certs Opaque 11 7m24s
kubernetes-dashboard-key-holder Opaque 2 3h53m
kubernetes-dashboard-token-qjkln kubernetes.io/service-account-token 3 3m58s
查看令牌
[root@localhost dashboard]# kubectl describe secret dashboard-admin-token-gxfmr -n kube-system
复制命令
token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4tZ3hmbXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiNjgwOTJkZTAtMDk3OC0xMWViLTljZWItMDAwYzI5MmU3ZWY0Iiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmRhc2hib2FyZC1hZG1pbiJ9.ksTrreEa-yJYx1YxQTm-IQ7wanV4zMqfLqvkwPuYAq8fsR40hKufY7l0UPp9Z6bTRWydNtqWBdgGdJGnzstNHR11g5xEFvE4RGqBbcowLqXGofIBCx-axMWdy6eFLmScrUKOjfK-0v5QP9RxoIawVqmhiWTKezfsmft474psjfQpQCNxPsuwASejEHhFI8NOZtXMLYQj1k_L_zS8FhskvpZkJ7VZo6r4O8HZcrgbGuB57_9eTpdl0Y8qB88ADHGXcwor-Kii4mtmS3XNNPWf0XfvYd22Y-AFrfx3g7l2ssTuJkNjo6osfK5hkGjf8etPyNtD7KUArooFE2rUE7bN4Q
再次访问web界面
选择使用令牌访问
复制上面生成的令牌
访问成功
更多推荐
已为社区贡献6条内容
所有评论(0)