简要概述:使用 kubeasz 快速部署 kubernetes 集群(使用Ansible脚本安装K8S集群)
一、kubeasz 项目地址:https://github.com/easzlab/kubeasz 我选用的3.0.1
二、kubernetes 集群快速部署过程
1、OS 版本
2、使用 pip 来安装 ansible
-# curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py
-# python get-pip.py
-# python -m pip install --upgrade “pip < 21.0”
-# pip install ansible -i https://mirrors.aliyun.com/pypi/simple/
3、相关节点免密登录 (ssh_scp.sh)
4、下载 kubeasz 部署工具
5、生成集群 k8s的配置文件
6、根据需求修改
7、使用 ./ezctl setup k8s-01 all 一键安装 kubernetes 集群即可
省略安装过程…
我测试的是3.0.1这个版本所以都是一键安装,不用每个应用单独ansible-playbook执行当然可以单独查看修改。
8、查看安装后的 kubernetes 集群状态
我自己的安装过程有两处报错。
一处node,一处master。刚好测试后期增加master和node.
TASK [kube-node : 设置node节点role]
**
changed: [192.168.10.207]
changed: [192.168.10.208]
fatal: [192.168.10.209]: FAILED! => {“changed”: true, “cmd”: "/opt/kube/bin/kubectl label node 192.168.10.209
kubernetes.io/role=node --overwrite", “delta”: “0:00:10.113122”, “end”: “2021-12-08 18:30:59.490445”, “msg”: "non-zero return
code", “rc”: 1, “start”: “2021-12-08 18:30:49.377323”, “stderr”: "Unable to connect to the server: net/http: TLS handshake
timeout", “stderr_lines”: [“Unable to connect to the server: net/http: TLS handshake timeout”], “stdout”: “”, “stdout_lines”:
[]}
…ignoring
TASK [kube-master : 启动 master 服务]
changed: [192.168.10.201]
changed: [192.168.10.202]
fatal: [192.168.10.203]: FAILED! => {“changed”: true, “cmd”: "systemctl daemon-reload && systemctl restart kube-apiserver &&
systemctl restart kube-controller-manager && systemctl restart kube-scheduler", “delta”: “0:00:16.082114”, “end”: "2021-12-08
18:19:13.772151", “msg”: “non-zero return code”, “rc”: 1, “start”: “2021-12-08 18:18:57.690037”, “stderr”: "Job for kube-
apiserver.service failed because a fatal signal was delivered to the control process.\nSee "systemctl status kube-
apiserver.service" and “journalctl -xe” for details.", “stderr_lines”: ["Job for kube-apiserver.service failed because a
fatal signal was delivered to the control process.", "See “systemctl status kube-apiserver.service” and “journalctl -xe”
for details."], “stdout”: “”, “stdout_lines”: []}cd /
具体步骤参照kubeasz,git上的文档即可,以我目前的级别我觉得这个kubeasz还是很好用的,符合我个人的操作习惯。
查资料的时候发现了,使用Rancher部署k8s集群,可视化的,等后期测试下先收藏。
https://www.jianshu.com/p/870ef7ba8723