Kubernetes 1.18的正式发布还有一段时间,目前最新的稳定版本是1.17.2,使用Easypack提供的Ansible脚本可以容易地进行一键部署。
安装步骤
Kubernetes 1.17.2,可参看下文进行快速环境搭建:
[root@host131 ~]# 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> 15m 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 ~]#
各组件版本
组件 | 版本 | 更新时间 | 获取地址 |
---|---|---|---|
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 | 1.10.1 | - | k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1 |
prometheus | 2.15.1 | 2019/12/25 | prom/prometheus:v2.15.1 |
因为dashboard暂未稳定,后续会继续更新dashboard组件至2.0版本
组件 | 版本 | 更新时间 | 获取地址 |
---|---|---|---|
dashboard | 2.0.0-rc3 | - | kubernetesui/dashboard:v2.0.0-rc3 |
安装日志
安装单机版Kubernetes
[root@host131 ansible]# ansible-playbook 10.all-in-one.yml
PLAY [all-in-one] **********************************************************************************************************************
...省略
PLAY RECAP *****************************************************************************************************************************
localhost : ok=109 changed=97 unreachable=0 failed=0
[root@host131 ansible]#
版本确认
[root@host131 ~]# which etcd
/usr/local/bin/etcd
[root@host131 ~]# etcdctl --version
etcdctl version: 3.3.18
API version: 2
[root@host131 ~]# docker version
Client: Docker Engine - Community
Version: 19.03.5
API version: 1.40
Go version: go1.12.12
Git commit: 633a0ea838
Built: Wed Nov 13 07:22:05 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.5
API version: 1.40 (minimum version 1.12)
Go version: go1.12.12
Git commit: 633a0ea838
Built: Wed Nov 13 07:28:45 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.10
GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339
runc:
Version: 1.0.0-rc8+dev
GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
docker-init:
Version: 0.18.0
GitCommit: fec3683
[root@host131 ~]# which flanneld
/usr/local/bin/flanneld
[root@host131 ~]# flanneld --version
v0.11.0
[root@host131 ~]# kubectl get cs
NAME STATUS MESSAGE ERROR
controller-manager Healthy ok
scheduler Healthy ok
etcd-0 Healthy {"health":"true"}
[root@host131 ~]# 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> 27m 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 ~]#
安装Prometheus
[root@host131 ansible]# ansible-playbook prometheus/tests/test.yml
PLAY [localhost] ***********************************************************************************************************************
TASK [prometheus : create dirs for prometheus] *****************************************************************************************
changed: [localhost] => (item=/etc/k8s/prometheus)
TASK [prometheus : create prometheus rbac yaml file] ***********************************************************************************
changed: [localhost]
TASK [prometheus : create prometheus configmap yaml file] ******************************************************************************
changed: [localhost]
TASK [prometheus : create prometheus deployment yaml file] *****************************************************************************
changed: [localhost]
TASK [prometheus : load prometheus image] **********************************************************************************************
changed: [localhost]
TASK [prometheus : create namespace specified when not existed] ************************************************************************
changed: [localhost]
TASK [prometheus : create prometheus service] ******************************************************************************************
changed: [localhost]
TASK [prometheus : confirm prometheus service state] ***********************************************************************************
FAILED - RETRYING: confirm prometheus service state (15 retries left).
changed: [localhost]
PLAY RECAP *****************************************************************************************************************************
localhost : ok=8 changed=8 unreachable=0 failed=0
[root@host131 ansible]#
Ansible脚本
github地址:https://github.com/liumiaocn/easypack/tree/master/k8s/ansible