Easypack: Ansible方式部署工具中升级Dashboard至2.0.0版

Source

在这里插入图片描述
在Easypack中提供了多套Kubernetes快速部署的工具,基于Bash脚本和Ansible的,Ansible的方式也有基于K3S和普通的Kubernetes的两种。这篇文章介绍一下普通Kubernetes版本下的Ansible部署工具中Dashboard升级至2.0.0版本的情况。

事前准备

本文使用Kubernetes 1.17.2,可参看下文进行快速环境搭建:

[root@host131 ansible]# kubectl get node -o wide
NAME              STATUS   ROLES    AGE     VERSION   INTERNAL-IP       EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION          CONTAINER-RUNTIME
192.168.163.131   Ready    <none>   2m25s   v1.17.2   192.168.163.131   <none>        CentOS Linux 7 (Core)   3.10.0-957.el7.x86_64   docker://19.3.5
[root@host131 ansible]# 
  • 事前环境确认: service、pod与deployment
[root@host131 ansible]# kubectl get service -A |grep dashboard
[root@host131 ansible]# kubectl get pod -A |grep dashboard
[root@host131 ansible]# kubectl get deployment -A |grep dashboard
[root@host131 ansible]# 

Dashboard安装

执行如下命令即可完成Metrics Server的安装

[root@host131 ansible]# ansible-playbook dashboard/tests/test.yml 

PLAY [localhost] *********************************************************************************************************************************

TASK [dashboard : create dirs for dashboard] *****************************************************************************************************
changed: [localhost] => (item=/etc/k8s/dashboard)

TASK [dashboard : create dashboard yaml service file] ********************************************************************************************
changed: [localhost]

TASK [dashboard : delete & create kubectl service] ***********************************************************************************************
changed: [localhost]

TASK [dashboard : confirm dashboard service state] ***********************************************************************************************
FAILED - RETRYING: confirm dashboard service state (15 retries left).
changed: [localhost]

TASK [dashboard : drop dashboard service account if exist then create the account] ***************************************************************
changed: [localhost]

TASK [dashboard : drop clusterrolebinding for dashboard if exist then create the clusterrolebinding] *********************************************
changed: [localhost]

PLAY RECAP ***************************************************************************************************************************************
localhost                  : ok=6    changed=6    unreachable=0    failed=0   

[root@host131 ansible]# 

注:FAILED - RETRYING: confirm dashboard service state (15 retries left).的提示信息没有问题,只是在等待服务启动的轮询而已。

结果确认

使用kubectl命令可以确认到,pod、deployment以及service全部生成并正常运行

[root@host131 ansible]# kubectl get pod -A |grep dashboard
kubernetes-dashboard   dashboard-metrics-scraper-7b8b58dc8b-wx6pp   1/1     Running   0          28s
kubernetes-dashboard   kubernetes-dashboard-6b77748b8f-gv68k        1/1     Running   0          28s
[root@host131 ansible]# kubectl get service -A |grep dashboard
kubernetes-dashboard   dashboard-metrics-scraper   ClusterIP   10.254.115.208   <none>        8000/TCP        34s
kubernetes-dashboard   kubernetes-dashboard        NodePort    10.254.169.84    <none>        443:33307/TCP   35s
[root@host131 ansible]# kubectl get deployment -A |grep dashboard
kubernetes-dashboard   dashboard-metrics-scraper   1/1     1            1           42s
kubernetes-dashboard   kubernetes-dashboard        1/1     1            1           42s
[root@host131 ansible]# 
  • 获取token
[root@host131 shell]# . ./common-util.sh 
[root@host131 shell]# display_dashboard_token
## dashboard_secrete: dashboard-admin-token-772qk
## dashboard_token: 
eyJhbGciOiJSUzI1NiIsImtpZCI6IjlCUzA5Y1l1UlBwRm1TaW9uN2UwX1o3N1N5QjBLRzgzUnp5UUZoOHhtbzQifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4tNzcycWsiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiNTU4NDAyNmYtZjU1Ni00MGVjLTk5MWEtMDEwODJkMjBmMDhkIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmRhc2hib2FyZC1hZG1pbiJ9.Yg59hCX7C1wYyc9NgL9tlJvml3iDcCBbDsTATnMEgRzalgkbCVh_tjEPVU3CmUuwrxs25gVICbkeBv0yPO4fWQR-f64DcF0fskW5ugiZ65IFpQJ8oq0UB2R0t4H7jQA1MQYUldAPQCUcDUtrLnMIUr2wR4oWcNmCr17RQJf3UjQyCprAb2cByNoFERhRdQbGRoYh1fvcKgn6vHupT5uxrd_Qac5JuuTElS69g6NchdOvxbxnEdv317YsEFUUWRw44hg5qf67lWN_4_gnz-x4qwdTaNyj5UneIizOEop4xGcYvpBeKPXEqGogNncsDvqBqwh6FZutcE-ntZso-tadOA
[root@host131 shell]# pwd
/root/easypack/k8s/shell
[root@host131 shell]# 

登录确认

使用上述token信息可以直接登录
在这里插入图片描述
可以切换至所有的命名空间角度进行状态确认
在这里插入图片描述
但是此时Pod等资源详细信息仍然无法确认
在这里插入图片描述

Ansible脚本

github地址:https://github.com/liumiaocn/easypack/tree/master/k8s/ansible

  • 各组件版本
组件 版本 更新时间 获取地址
cfssl 1.2 2016/3/30 https://pkg.cfssl.org/
flannel 0.11.0 2019/1/29 https://github.com/coreos/flannel
pause 3.1 - gcr.io/google_containers/pause-amd64:3.1
kubernetes 1.17.2 2020/1/21 https://dl.k8s.io
etcd 3.3.18 2019/11/27 https://github.com/etcd-io/etcd/releases
docker 19.03.5 2019/11/14 https://download.docker.com/
cni 0.8.5 2020/1/22 https://github.com/containernetworking/plugins/releases
coredns 1.6.7 2020/1/28 coredns/coredns:1.6.7
dashboard 2.0.0-rc3 2020/1/31 kubernetesui:v2.0.0-rc3
prometheus 2.15.1 2019/12/25 prom/prometheus:v2.15.1
metrics server 0.3.6 2019/10/15 k8s.gcr.io/metrics-server-amd64 :v0.3.6
发布了1140 篇原创文章 · 获赞 1362 · 访问量 414万+