前言
环境:centos7.9 docker-ce-20.10.9 kubernetes-version v1.22.6 kubernetes-dashboard v2.5.0
什么是dashboard
dashboard是kubernetes集群的Web UI,用户可以通过dashboard进行管理集群内所有资源对象,例如查看资源对象的运行情况,部署新的资源对象,伸缩deployment中的pod数量等等一系列操作。
部署dashboard
方法一、直接一键运行,默认dashboard以aip方式运行
[root@master ~]
方法二、先下载yaml到本地再运行,本篇使用NodePort方式运行dashboard
[root@master ~]
[root@master ~]
32 kind: Service
33 apiVersion: v1
34 metadata:
35 labels:
36 k8s-app: kubernetes-dashboard
37 name: kubernetes-dashboard
38 namespace: kubernetes-dashboard
39 spec:
40 type: NodePort
41 ports:
42 - port: 443
43 targetPort: 8443
44 nodePort: 30001
45 selector:
46 k8s-app: kubernetes-dashboard
47 ---
[root@master ~]
[root@master ~]
NAME READY STATUS RESTARTS AGE
dashboard-metrics-scraper-c45b7869d-9mkr8 1/1 Running 0 87s
kubernetes-dashboard-764b4dd7-ccgqn 1/1 Running 0 88s
[root@master ~]
[root@master ~]
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/dashboard-metrics-scraper ClusterIP 10.101.244.233 <none> 8000/TCP 5m58s
service/kubernetes-dashboard NodePort 10.101.188.28 <none> 443:30001/TCP 5m58s
[root@master ~]
web访问dashboard可视化面板
访问dashboard默认是https://master_ip:30001/,如下图所示: 发现dashboard有两种登陆方式,一种是Token方式,另外一种是使用kubeconfig方式,下面分别介绍这两种方式登陆。
方式一、使用Token方式登陆
[root@master ~]
serviceaccount/dashboard-admin created
[root@master ~]
clusterrolebinding.rbac.authorization.k8s.io/dashboard-admin created
[root@master ~]
kube-system dashboard-admin-token-jgxt9 kubernetes.io/service-account-token 3 8m4s
[root@master ~]
Name: dashboard-admin-token-jgxt9
Namespace: kube-system
Labels: <none>
Annotations: kubernetes.io/service-account.name: dashboard-admin
kubernetes.io/service-account.uid: 93aeb666-79f0-4374-857d-15db559ce4d8
Type: kubernetes.io/service-account-token
Data
====
ca.crt: 1099 bytes
namespace: 11 bytes
token: eyJhbGciOiJSUzI1NiIsImtpZCI6ImF0Yjhta24xLUlhV2RTX0ZFZXgxVDlmQk5fSFVtWTRMMWgzbmJHVXROU0UifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4tamd4dDkiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiOTNhZWI2NjYtNzlmMC00Mzc0LTg1N2QtMTVkYjU1OWNlNGQ4Iiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmRhc2hib2FyZC1hZG1pbiJ9.fBXTIGWo1sT4sc95RV074RwiSbfjT7wkZDcHcPOyddgGYlqob6H-E_7bAv1aIy11jgsvv5BChnKO-3PkDG16e9P6t2ozjW1l9VcHnw20lIliAEjnAnLSDBPAn6xHBOKHVvjAUUOYTN5a87ZgbbsLMnbu2XnzYpCIOfIkrYi4fVOzew-PiUhrwZJTal2TxMTnBxG2SxazyUt1SjHN7Azo-QVtfdjKKRIZAPeHqn211y3Ygsclp5TO3z747mSjB0s7q6Svyv-HTVpu25xMgInYXzK-cNzhG6O1tjWSWihlFkf6PzxcaejfuiMWovxMY6lyL6MCNjUM_iroO_JhKJ8QqA
[root@master ~]
方式二、使用kubeconfig方式登陆 (先不讲,配置有点复杂)
|