KubernetesNotes3:集群安装Web可视化界面

KubernetesNotes3:集群安装Web可视化界面

Created
Nov 20, 2021 01:30 PM
Last Edited
Last updated December 3, 2021
Tags
 

1. 部署Dashboard

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.4.0/aio/deploy/recommended.yaml
查看安装
notion image

2. 设置访问端口

2.1本地访问

kubectl proxy
访问以下地址:
notion image
 

2.2 公网IP访问设置

kubectl -n kubernetes-dashboard edit service kubernetes-dashboard
type:Cluster改为type:NodePort
notion image
获取nodeport对外开放的https端口,注意这里为30511端口
kubectl -n kubernetes-dashboard get service kubernetes-dashboard
notion image
同时启动监控指标收集服务,不然会dashborad无法展示数据图表
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.4.0/aio/deploy/recommended.yaml
notion image
创建dashboard对应的admin账户
vi dashboard-admin.yml
apiVersion: v1 kind: ServiceAccount metadata: name: admin-user namespace: kubernetes-dashboard --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: admin-user roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount name: admin-user namespace: kubernetes-dashboard
 
kubectl apply -f dashboard-admin.yml
然后通过如下命令获取登录的token
kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')
root@docker01:/home# kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}') Name: admin-user-token-q7s6k Namespace: kubernetes-dashboard Labels: <none> Annotations: kubernetes.io/service-account.name: admin-user kubernetes.io/service-account.uid: 2cbe2d0d-844a-4323-9fab-826a83d8f293 Type: kubernetes.io/service-account-token Data ==== ca.crt: 1099 bytes namespace: 20 bytes token: eyJhbGciOiJSUzI1NiIsImtpZCI6InhYZ1BNbnFrYk9iTk41T1hzeGxrbk5DSVdkRXBOcXludEdCZFJVQXN3NFkifQ.eyJpc3MiOiJrdWJlcm5ld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mVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLXE3czZrIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIyY2JlMmQwZC04NDRhLTQzMjMtOWZhYi04MjZhODNkOGYyOTMiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6YWRtaW4tdXNlciJ9.l_p0f7C1tCMK6vYkzScH5EYOdN8g0Q4jC6JLsbgA3730jRYLJUOPIbHMbRG66xk4O94W-o7UspmVfHVIx0o9-0n7jRlPC_JGJ15P29HyOJD8BxOYkKMWgVRMPgQSjc586vdaYEgouNDjIjDfua87WESvLkdSCMacUUks-5ABonloGrW1i6k2CDoYu9kl5IpIdkyrQmqgDd2xJZZsok-XXLtT_gAARvgkNNAHOIHeTvcYgRNek13Qx3CMeijVFivp84uSci0We19mlO3QQ16NblTbRe9Yh64PDQBCC4q2jbEuV3NBEhAPjvN8C-vbC-VROqGaVZnFuG0p7aKpDgtRQw
notion image
进入面板,每隔一段时间,需要重新输入令牌。
notion image