共计 4422 个字符,预计需要花费 12 分钟才能阅读完成。
一、环境介绍
k8s 版本:v1.22.2
dashboard 版本:v2.5.1
装置前留神 k8s 的版本与将要装置的 dashbaord 版本是否兼容,具体查看 https://github.com/kubernetes…
二、dashbord 装置
下载官网 yaml 文件并且进行部署
root@master01:~/dashboard# wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.5.1/aio/deploy/recommended.yaml
--2023-01-03 20:51:21-- https://raw.githubusercontent.com/kubernetes/dashboard/v2.5.1/aio/deploy/recommended.yaml
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7621 (7.4K)
Saving to:‘recommended.yaml’recommended.yaml 100%[=================================================================================================>] 7.44K --.-KB/s in 0.004s
2023-01-03 20:51:22 (1.95 MB/s) -‘recommended.yaml’saved [7621/7621]
批改其网络为 NodePort 模式,不便宿主机进行拜访,留神其 40 行与 44 行地位内容的变更。30 ---
31
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
48 ---
部署 dashboard
root@master01:~/dashboard# 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
deployment.apps/kubernetes-dashboard created
service/dashboard-metrics-scraper created
deployment.apps/dashboard-metrics-scraper created
查看 dashbaord 相干 pod 状态
root@master01:~/dashboard# kubectl get po -n kubernetes-dashboard
NAME READY STATUS RESTARTS AGE
dashboard-metrics-scraper-c45b7869d-rh4p7 1/1 Running 0 4m2s
kubernetes-dashboard-79b5779bf4-bvbsf 1/1 Running 0 4m2s
在宿主机应用浏览器胜利拜访到 dashboard
将 kubernetes-dashboard 绑定 cluster-admin 权限。
root@master01:~/dashboard# kubectl create clusterrolebinding dashboard-cluster-admin --clusterrole=cluster-admin --serviceaccount=kubernetes-dashboard:kubernetes-dashboard
clusterrolebinding.rbac.authorization.k8s.io/dashboard-cluster-admin created
从默认创立的 secret 中找到相干的 tocken 值粘贴到浏览器对应地位,留神 kubernetes v1.24.0 更新之后进行创立 ServiceAccount 不会主动生成 Secret 须要对其手动创立本文应用的版本为 1.22 版本,所以会主动生成 Secret。具体阐明请查看:https://cloud.tencent.com/dev…
root@master01:~/dashboard# kubectl get secrets -n kubernetes-dashboard
NAME TYPE DATA AGE
default-token-625rd kubernetes.io/service-account-token 3 11m
kubernetes-dashboard-certs Opaque 0 11m
kubernetes-dashboard-csrf Opaque 1 11m
kubernetes-dashboard-key-holder Opaque 2 11m
kubernetes-dashboard-token-ffsvd kubernetes.io/service-account-token 3 11m
root@master01:~/dashboard# kubectl describe secrets kubernetes-dashboard-token-ffsvd -n kubernetes-dashboard
Name: kubernetes-dashboard-token-ffsvd
Namespace: kubernetes-dashboard
Labels: <none>
Annotations: kubernetes.io/service-account.name: kubernetes-dashboard
kubernetes.io/service-account.uid: 7cd8d6da-b722-4791-b432-b4459d1931c2
Type: kubernetes.io/service-account-token
Data
====
ca.crt: 1350 bytes
namespace: 20 bytes
token: eyJhbGciOiJSUzI1NiIsImtpZCI6InpjRXhWTDd6MmlPRmoyS0FEbDVIWFFZb29SaWlkRjlORVNnYm9GUEdKSmMifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZC10b2tlbi1mZnN2ZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjdjZDhkNmRhLWI3MjItNDc5MS1iNDMyLWI0NDU5ZDE5MzFjMiIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlcm5ldGVzLWRhc2hib2FyZDprdWJlcm5ldGVzLWRhc2hib2FyZCJ9.fXJcuj5pwsAf-9_OPY2FXV7Lo5wqcfT-JkqFpIW1SwS0JtTR1ndbjNhZX0Wo5d4ds2ZCSMHnf1V0sII3mzRIF8iYPKiRxRgowEDhPFTW3gOqMaeirmpdAuMT4UcaV6HibH0wIipE74RYiPLMdTC7Y5Mu1sFQO8gKNAHWj3k9mPblVYK9IUYvFiVIJm5UNBVQpvxZYyrjld7v9UCi0RWyHcnNA8DCY6nlbPbyUp7gYwfEGUPeJo_4ewQ4AFktiuTA6lbSWqL1AB8WOzIcEfjCqZaRUbnPKt6HZGNNglCSiRTyHz2maGeH9mqk7cF7vxVQ3uzewGPvOnEOg1SSbkGhUA
在浏览器登录后成果,留神左下角显示的 CPU 及内存应用监控须要装置 metric-server 才能够失常显示,否则会显示空白。
ps:本文操作已在自己环境中操作胜利,如有问题亦或表述不清的中央欢送斧正。
正文完
发表至: kubernetes
2023-01-03