Docker&Kubernetes ❀ Kubernetes集群 - DashBoard服务(Web管理)安装部署
Posted 无糖可乐没有灵魂
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker&Kubernetes ❀ Kubernetes集群 - DashBoard服务(Web管理)安装部署相关的知识,希望对你有一定的参考价值。
文章目录
1、服务下载
DashBoard为Kubernetes的一个基于Web的用户界面,可以使用DashBoard部署容器化的应用,还可以监控应用与节点状态,执行故障排查与管理资源等操作,是Kubernetes官方推荐的一个使用方式;
[root@master ~]# wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-rc7/aio/deploy/recommended.yaml
由于可能网络原因导致YAML文件无法下载,因此可以通过CSDN下载对应YAML文件内容,直接复制即可,若通过CSDN下载,则直接跳过第二步(下载的文件已经完成修改);https://blog.csdn.net/qq_42197548/article/details/122671280?spm=1001.2014.3001.5501
2、创建资源
2.1 修改YAML文件
[root@master ~]# vim recommended.yaml
~
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kubernetes-dashboard
spec:
type: NodePort
ports:
- port: 443
targetPort: 8443
nodePort: 30443
selector:
k8s-app: kubernetes-dashboard
~
2.2 调用YAML文件
[root@master ~]# 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
Warning: spec.template.spec.nodeSelector[beta.kubernetes.io/os]: deprecated since v1.14; use "kubernetes.io/os" instead
deployment.apps/kubernetes-dashboard created
service/dashboard-metrics-scraper created
Warning: spec.template.metadata.annotations[seccomp.security.alpha.kubernetes.io/pod]: deprecated since v1.19, non-functional in v1.25+; use the "seccompProfile" field instead
deployment.apps/dashboard-metrics-scraper created
2.3 查看创建资源
[root@master ~]# kubectl get pods,svc -n kubernetes-dashboard
NAME READY STATUS RESTARTS AGE
pod/dashboard-metrics-scraper-5d74b4cf4c-785wb 1/1 Running 0 2m55s
pod/kubernetes-dashboard-6b88c86848-nqw8d 1/1 Running 0 2m55s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/dashboard-metrics-scraper ClusterIP 10.111.175.25 <none> 8000/TCP 2m55s
service/kubernetes-dashboard NodePort 10.99.28.45 <none> 443:30443/TCP 2m55s
3、创建admin超级管理员权限
如果没有admin账户,则该页面无超级权限
[root@master ~]# kubectl create serviceaccount dashboard-admin -n kube-system
serviceaccount/dashboard-admin created
[root@master ~]# kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=kube-system:dashboard-admin
clusterrolebinding.rbac.authorization.k8s.io/dashboard-admin created
4、获取Token值
[root@master ~]# kubectl describe secrets -n kube-system $(kubectl -n kube-system get secret | awk '/dashboard-admin/print $1')
Name: dashboard-admin-token-9bnl6
Namespace: kube-system
Labels: <none>
Annotations: kubernetes.io/service-account.name: dashboard-admin
kubernetes.io/service-account.uid: 6f30f13e-a69b-4ece-8970-a8bc82bd8a4f
Type: kubernetes.io/service-account-token
Data
====
ca.crt: 1099 bytes
namespace: 11 bytes
token: eyJhbGciOiJSUzI1NiIsImtpZCI6IkliQUpIOFdHZUpsMWlVQTBDR044RUw5ZlBhRTU4dzE1R0h6TVBaUzRCOEkifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4tOWJubDYiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiNmYzMGYxM2UtYTY5Yi00ZWNlLTg5NzAtYThiYzgyYmQ4YTRmIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmRhc2hib2FyZC1hZG1pbiJ9.ei9d-o8jT0dbtRHZy-kiU7zQjDZA3Rr052weRThky1FUFckFrVfudkqRy1j25t3KQPJxrMeaxMlgYEX6i46yL-q69ItRdHm6wYOkCenpEw09RImqwNwSi298u1BQLbFsNER0gGWSj8ZC8ODN946C2LoJlILEiIw_n19eqdqQjLw5t1LlCU8938bYxwHwFUHT72mFVkEL2KRwMEuG52pm54ffW_gQAwvHe4G0Yb-0fTLG9C-xlnqcA-QmFsPxVuE3VhxYTATjPSDK58NokKww4Y6Myq-rBPqRpDwxe4eX7Qe56elIpHiPelJBz_BgLl-C5iOvPPTZ4N9qfU1RpQ51Gg
5、页面导入Token值
打开DashBoard服务Web页面:https://[master_ip]:30443
选择[Token]-[输入token]-[登录]
将第4步的Token值,复制到当前页面的输入框内即可,点击登录即可使用admin账户登录;
以上是关于Docker&Kubernetes ❀ Kubernetes集群 - DashBoard服务(Web管理)安装部署的主要内容,如果未能解决你的问题,请参考以下文章
Docker&Kubernetes ❀ Kubernetes集群安装部署过程与常见的错误解决方法
Docker&Kubernetes ❀ Kubernetes集群安装部署过程与常见的错误解决方法
Docker&Kubernetes ❀ Kubernetes集群实践与部署笔记知识点梳理
Docker&Kubernetes ❀ Docker 容器技术笔记链接梳理