Kubeadm搭建高可用K8S(四)Dashboard安装配置
Kubeadm搭建高可用K8S之搭建k8s-dashboard且配置谷歌浏览器访问
·
安装
# 1.先将镜像文件上传到两个worker节点,然后解压
docker load -i dashboard_2_0_0.tar.gz
docker load -i metrics-scrapter-1-0-1.tar.gz
# 2.将kubernetes-dashboard.yaml上传到master节点
kubectl apply -f kubernetes-dashboard.yaml
# 3.yaml配置将dashboard安装在了kubernetes-dashboard命名空间下
kubectl get pods -n kubernetes-dashboard
# 4.查看网络配置
kubectl get svc -n kubernetes-dashboard
# 显示如下Running即可
NAME READY STATUS RESTARTS AGE
dashboard-metrics-scraper-xxx 1/1 Running 0 7m14s
kubernetes-dashboard-xxx 1/1 Running 0 6m55s
# 5.修改 service type 类型变成 NodePort
kubectl edit svc kubernetes-dashboard -n kubernetes-dashboard
# 把 type: ClusterIP 变成 type: NodePort,保存退出即可。
kubectl get svc -n kubernetes-dashboard
# 显示如下:NodePort中30940即为访问端口
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
dashboard-xx ClusterIP 10.10.182.138 <none> 8000/TCP 25m
kubernetes-xx NodePort 10.10.101.23 <none> 443:30940/TCP 25m
注意:初始化时候,UI界面访问使用的是HTTPS,且谷歌浏览器访问不了
Token登录
# 创建管理员 token,具有查看任何空间的权限,可以管理所有资源对象
kubectl create clusterrolebinding dashboard-cluster-admin --clusterrole=cluster-admin --serviceaccount=kubernetes-dashboard:kubernetes-dashboard
# 查看 kubernetes-dashboard 名称空间下的 secret
kubectl get secret -n kubernetes-dashboard
# 找到对应带Token的选项
kubectl describe secret kubernetes-dashboard-token-xxx -n kubernetes-dashboard
# 保存Token,将Token粘贴到UI界面即可登录
Config登录
cd /etc/kubernetes/pki
# 【1】创建 cluster 集群
kubectl config set-cluster kubernetes --certificate-authority=./ca.crt --server="https://192.168.74.10:6443" --embed-certs=true --kubeconfig=/root/dashboard-admin.conf
# 查看如下:
cat /root/dashboard-admin.conf
apiVersion: v1
clusters:
- cluster:
certific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V04yVlAxZWdXNnF0Q0ZMZzNjZFJ2CmtYTlJleDJxbzFnK0todlUwRUwybXRiTk1xWFdqcUVvaDZlUE8rYmNGQ3Y5SXZJRWlEMVovOEowMzYyVHhtNzAKY3lBdDZGZnJXcFZ4Uk03Y09aL0xQQzR1TlV3L2V6dGpvUG9KOUJ5emcxdUVmeCszK01mNW1UNk0weXcvTTRtbgpwMjhQbE9QYWpseWtMaUVObktqSzFoNkwwVkl2cktISkVuQU56bGNqZU1xNkx2WDMvWm5sWHFHbUlXQ1VuV2wwCjllcUNiUFNLaHBIQ0FBZzdxdUF0ZmpMYk9ac0g3SXYvMGU4TgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
server: https://192.168.74.10:6443
name: kubernetes
contexts: null
current-context: ""
kind: Config
preferences: {}
users: null
# 【2】创建 credentials
# 创建 credentials 需要使用上面的 kubernetes-dashboard-token-xxxx 对应的 token 信息
DEF_NS_ADMIN_TOKEN=$(kubectl get secret kubernetes-dashboard-token-m6cl6 -n kubernetes-dashboard -o jsonpath={.data.token}|base64 -d)
kubectl config set-credentials dashboard-admin --token=$DEF_NS_ADMIN_TOKEN --kubeconfig=/root/dashboard-admin.conf
# 再次查看如下:其中可见dashboard-admin用户的Token与Token登录时候的一致
cat /root/dashboard-admin.conf
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM1ekNDQWMrZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeE1USXlOVEExTWpBME1Wb1hEVE14TVRJeU16QTFNakEwTVZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTDcvCmpVRE03dHh6aUtGMDV2SmExa3BGNmlOQWZIQWprZHp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tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
server: https://192.168.74.10:6443
name: kubernetes
contexts: null
current-context: ""
kind: Config
preferences: {}
users:
- name: dashboard-admin
user:
token: eyJhbGciOiJSUzI1NiIsImtpZCI6InlDZXRZWVR4R2pxaVVCcDRSSWFOVTBwYjRIcDRtcmtYOElaQ0VmTkRrazQifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZC10b2tlbi1tNmNsNiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjhmYTJhZjk2LWZhNmYtNGI5YS05OTNmLTk1NjU1NDU3Mzk3OSIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlcm5ldGVzLWRhc2hib2FyZDprdWJlcm5ldGVzLWRhc2hib2FyZCJ9.npxvSmb7IZjlaler9-De-fm8gCckvBNGSbge6nJ7UYGIW4NKPC_rQyK_MkTMtNJ4pp_9QTZ45oy_ZKb27qoIEh3Qsy4gRr-eWSXWE3878MsfwXu0NhnjSs-qrlD5ewG-tVRqzX1S-0rj10A0C2G7yIpcW_pqm278eoIwofmIQonBZFs7rNsIGiJjjKCVXRhbNIeRqbSnK7ucCBoDb-K5XhZMsZGDul44SZ9ZOatx4rqLxjZqt5sMLDeSKjm8rAbrdURfWKgIa082vrrcvMYglKeRG9TpORsGefeZoxu_mhQGLRtd0QibNtjcoqrfHcd8KF3o2PUZh32Fqm5mrJacHQ
# 【3】创建 context
kubectl config set-context dashboard-admin@kubernetes --cluster=kubernetes --user=dashboard-admin --kubeconfig=/root/dashboard-admin.conf
# 再次查看如下:其中可见contexts下面多了些内容
cat /root/dashboard-admin.conf
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM1ekNDQWMrZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeE1USXlOVEExTWpBME1Wb1hEVE14TVRJeU16QTFNakEwTVZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTDcvCmpVRE03dHh6aUtGMDV2SmExa3BGNmlOQWZIQWprZHpnVFdML3lwUys5OUNlUERNd3prbXljY2hsVStXS1dsbzcKakZqb1U2RXQrVzE4TUpWSjI2bEQ3RjhHWkhFdEtDU0JpSk1RazFkV1VTdndZUTRCWlQxK0U0aHNJN0p4OTJIdAo3TXdhaW9jSXBBb3J0aDJCZ1RsTG9wWlFFRU5vNUt6WVVJK1AxSitta0MrdkhvVUM4aklWK2wrWEZkVDhubzZvClNtNlM5WWdvemFLYXRsWXA4OEMrSFc2ZVhmZmRQRDRHWlhZamw1bjBJeFlWc2lic0dMK3JkNXc3aGJsR3dueXYKMEdjL0I0U2F4a3VMdTBnYmQ2M1Q1K2hQa2FRdnpUQnJPdW8yWk5IcVZhWW9uakpRaGI2MWdCdjFsWmt3dVpvVgpsWERjdkZUVnN1UVkyWlJ1SjZzQ0F3RUFBYU5DTUVBd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0hRWURWUjBPQkJZRUZEM3VXVjhNbzN1RkFYQzFxaGdKTHNnRU8vMEZNQTBHQ1NxR1NJYjMKRFFFQkN3VUFBNElCQVFDUHI3RmY3OG1RdGQyQ0pvSGN5MHp0L3RuUXUzakJxRE1yY2dnWU00S3VmTG9hd2FZZwp1WFlKR3VONmRjZVlGM0RiazJUUDQ3Q01QNS8rQ0xTQVRtcHdtSnArWE1qV04yVlAxZWdXNnF0Q0ZMZzNjZFJ2CmtYTlJleDJxbzFnK0todlUwRUwybXRiTk1xWFdqcUVvaDZlUE8rYmNGQ3Y5SXZJRWlEMVovOEowMzYyVHhtNzAKY3lBdDZGZnJXcFZ4Uk03Y09aL0xQQzR1TlV3L2V6dGpvUG9KOUJ5emcxdUVmeCszK01mNW1UNk0weXcvTTRtbgpwMjhQbE9QYWpseWtMaUVObktqSzFoNkwwVkl2cktISkVuQU56bGNqZU1xNkx2WDMvWm5sWHFHbUlXQ1VuV2wwCjllcUNiUFNLaHBIQ0FBZzdxdUF0ZmpMYk9ac0g3SXYvMGU4TgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
server: https://192.168.74.10:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: dashboard-admin
name: dashboard-admin@kubernetes
current-context: ""
kind: Config
preferences: {}
users:
- name: dashboard-admin
user:
token: eyJhbGciOiJSUzI1NiIsImtpZCI6InlDZXRZWVR4R2pxaVVCcDRSSWFOVTBwYjRIcDRtcmtYOElaQ0VmTkRrazQifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZC10b2tlbi1tNmNsNiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjhmYTJhZjk2LWZhNmYtNGI5YS05OTNmLTk1NjU1NDU3Mzk3OSIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlcm5ldGVzLWRhc2hib2FyZDprdWJlcm5ldGVzLWRhc2hib2FyZCJ9.npxvSmb7IZjlaler9-De-fm8gCckvBNGSbge6nJ7UYGIW4NKPC_rQyK_MkTMtNJ4pp_9QTZ45oy_ZKb27qoIEh3Qsy4gRr-eWSXWE3878MsfwXu0NhnjSs-qrlD5ewG-tVRqzX1S-0rj10A0C2G7yIpcW_pqm278eoIwofmIQonBZFs7rNsIGiJjjKCVXRhbNIeRqbSnK7ucCBoDb-K5XhZMsZGDul44SZ9ZOatx4rqLxjZqt5sMLDeSKjm8rAbrdURfWKgIa082vrrcvMYglKeRG9TpORsGefeZoxu_mhQGLRtd0QibNtjcoqrfHcd8KF3o2PUZh32Fqm5mrJacHQ
# 【4】切换 context 的 current-context 是 dashboard-admin@kubernetes
kubectl config use-context dashboard-admin@kubernetes --kubeconfig=/root/dashboard-admin.conf
# 再次查看如下:其中可见current-context有值了
cat /root/dashboard-admin.conf
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM1ekNDQWMrZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeE1USXlOVEExTWpBME1Wb1hEVE14TVRJeU16QTFNakEwTVZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTDcvCmpVRE03dHh6aUtGMDV2SmExa3BGNmlOQWZIQWprZHpnVFdML3lwUys5OUNlUERNd3prbXljY2h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tCg==
server: https://192.168.74.10:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: dashboard-admin
name: dashboard-admin@kubernetes
current-context: dashboard-admin@kubernetes
kind: Config
preferences: {}
users:
- name: dashboard-admin
user:
token: eyJhbGciOiJSUzI1NiIsImtpZCI6InlDZXRZWVR4R2pxaVVCcDRSSWFOVTBwYjRIcDRtcmtYOElaQ0VmTkRrazQifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZC10b2tlbi1tNmNsNiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjhmYTJhZjk2LWZhNmYtNGI5YS05OTNmLTk1NjU1NDU3Mzk3OSIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlcm5ldGVzLWRhc2hib2FyZDprdWJlcm5ldGVzLWRhc2hib2FyZCJ9.npxvSmb7IZjlaler9-De-fm8gCckvBNGSbge6nJ7UYGIW4NKPC_rQyK_MkTMtNJ4pp_9QTZ45oy_ZKb27qoIEh3Qsy4gRr-eWSXWE3878MsfwXu0NhnjSs-qrlD5ewG-tVRqzX1S-0rj10A0C2G7yIpcW_pqm278eoIwofmIQonBZFs7rNsIGiJjjKCVXRhbNIeRqbSnK7ucCBoDb-K5XhZMsZGDul44SZ9ZOatx4rqLxjZqt5sMLDeSKjm8rAbrdURfWKgIa082vrrcvMYglKeRG9TpORsGefeZoxu_mhQGLRtd0QibNtjcoqrfHcd8KF3o2PUZh32Fqm5mrJacHQ
# 将文件导出,在UI上使用config登录
sz dashboard-admin.conf
UI创建Pod
通过Nginx示例,上传镜像到两个worker节点,并解压
UI界面上:右上角加号 -->> create from form -->>填写完毕,点击Deploy -->> 等待启动
–>> 点击左侧 Service菜单,查看映射端口 -->>浏览器打开验证
应用名称:nginx
容器镜像:nginx
pod 数量:2
service: external 外部网络
port:80 #集群内的 pod 互相通信用的端口类型
targetport:80 #目标端口,也就是最终端口,也就是 pod 的端口
nodeport #是集群外流量访问集群内服务的端口
有时候,自动映射外部访问端口失败,手工修改
kubectl get svc -n <namespace>
kubectl edit svc <service-name> -n <namespace>
# 将ClusterIP修改为NodePort
配置谷歌浏览器打开Dashboard页面
mkdir key && cd key
#生成证书
openssl genrsa -out dashboard.key 2048
openssl req -new -out dashboard.csr -key dashboard.key -subj '/CN=192.168.246.200'
openssl x509 -req -in dashboard.csr -signkey dashboard.key -out dashboard.crt
#删除原有的证书secret
kubectl delete secret kubernetes-dashboard-certs -n kubernetes-dashboard
#创建新的证书secret
kubectl create secret generic kubernetes-dashboard-certs --from-file=dashboard.key --from-file=dashboard.crt -n kubernetes-dashboard
#查看pod
kubectl get pod -n kubernetes-dashboard
#重启pod
kubectl delete pod <pod name> -n kubernetes-dashboard
更多推荐
已为社区贡献5条内容
所有评论(0)