kubeasz 部署v1.27.3 k8s
致力于提供快速部署高可用k8s集群的工具, 同时也努力成为k8s实践、使用的参考书;基于二进制方式部署和利用实现自动化;既提供一键安装脚本, 也可以根据安装指南分步执行安装各个组件。
·
kubeasz简介
kubeasz 致力于提供快速部署高可用k8s
集群的工具, 同时也努力成为k8s
实践、使用的参考书;基于二进制方式部署和利用ansible-playbook
实现自动化;既提供一键安装脚本, 也可以根据安装指南
分步执行安装各个组件。
部署步骤
前置准备
i.规划集群
角色 | 数量 | 描述 |
---|---|---|
部署节点 | 1 | 运行ansible/ezctl命令,一般复用第一个master节点 |
etcd节点 | 3 | 注意etcd集群需要1,3,5,...奇数个节点,一般复用master节点 |
master节点 | 2 | 高可用集群至少2个master节点 |
node节点 | n | 运行应用负载的节点,可根据需要提升机器配置/增加节点数 |
ii.部署节点需和其他节点ssh打通
下载ezdown
推荐版本对照
Kubernetes version | 1.22 | 1.23 | 1.24 | 1.25 | 1.26 | 1.27 | 1.28 | 1.29 |
kubeasz version | 3.1.1 | 3.2.0 | 3.6.2 | 3.6.2 | 3.6.2 | 3.6.2 | 3.6.2 | 3.6.3 |
i.下载kubeasz
export release=3.6.2
wget https://github.com/easzlab/kubeasz/releases/download/${release}/ezdown
ii.为如下域名配置加速或者代理
x.x.x.x github.com objects.githubusercontent.com docker.io registry-1.docker.io production.cloudflare.docker.com dl.k8s.io cdn.dl.k8s.io
在部署节点编排k8s安装
chmod +x ezdown
#初始化
./ezdown -D -k v1.27.3
#容器化运行kubeasz
./ezdown -S
#创建新集群 k8s-01
#docker exec -it kubeasz ezctl new k8s-01
2024-05-16 11:21:35 DEBUG generate custom cluster files in /etc/kubeasz/clusters/k8s-01
2024-05-16 11:21:35 DEBUG set versions
2024-05-16 11:21:35 DEBUG cluster k8s-01: files successfully created.
2024-05-16 11:21:35 INFO next steps 1: to config '/etc/kubeasz/clusters/k8s-01/hosts'
2024-05-16 11:21:35 INFO next steps 2: to config '/etc/kubeasz/clusters/k8s-01/config.yml'
根据实际情况修改配置文件
vim /etc/kubeasz/clusters/k8s-01/config.yml
...
CLUSTER_NAME: "k8s-edge-cluster"
K8S_VER: "1.27.3"
#master节点证书配置
MASTER_CERT_HOSTS:
- "10.x.5.122"
- "10.x.1.213"
- "10.x.35.13"
- "域名"
...
vim /etc/kubeasz/clusters/k8s-01/hosts
...
[etcd]
10.x.5.122
10.x.1.213
10.x.35.13
[kube_master]
10.x.5.122 k8s_nodename='master-01'
10.x.1.213 k8s_nodename='master-02'
10.x.35.13 k8s_nodename='master-03'
[kube_node]
10.x.34.249 k8s_nodename='worker-01'
...
分步安装
#建议使用alias命令
#查看~/.bashrc 文件应该包含:alias dk='docker exec -it kubeasz'
source ~/.bashrc
初始化
#dk ezctl setup k8s-01 01
...
ansible-playbook -i clusters/k8s-01/hosts -e @clusters/k8s-01/config.yml playbooks/01.prepare.yml
...
部署etcd
i.执行安装
#dk ezctl setup k8s-01 02
...
ansible-playbook -i clusters/k8s-01/hosts -e @clusters/k8s-01/config.yml playbooks/02.etcd.yml
...
ii.集群状态
#export NODE_IPS="10.x.5.122 10.x.1.213 10.x.35.13"
for ip in ${NODE_IPS}; do ETCDCTL_API=3 /opt/kube/bin/etcdctl --endpoints=https://${ip}:2379 --cacert=/etc/kubernetes/ssl/ca.pem --cert=/etc/kubernetes/ssl/etcd.pem --key=/etc/kubernetes/ssl/etcd-key.pem endpoint health; done
#输出内容
...
https://10.x.5.122:2379 is healthy: successfully committed proposal: took = 15.96023ms
https://10.x.1.213:2379 is healthy: successfully committed proposal: took = 16.849881ms
https://10.x.35.13:2379 is healthy: successfully committed proposal: took = 20.668937ms
...
iii.证书有效期
#openssl x509 -in /etc/kubernetes/ssl/etcd.pem -noout -text |egrep 'Not After'
...
Not After : May 3 09:09:00 2074 GMT
...
部署runtime
#dk ezctl setup k8s-01 03
...
ansible-playbook -i clusters/k8s-01/hosts -e @clusters/k8s-01/config.yml playbooks/03.runtime.yml
...
部署master节点
#dk ezctl setup k8s-01 04
...
ansible-playbook -i clusters/k8s-01/hosts -e @clusters/k8s-01/config.yml playbooks/04.kube-master.yml
...
部署node节点
#dk ezctl setup k8s-01 05
...
ansible-playbook -i clusters/k8s-01/hosts -e @clusters/k8s-01/config.yml playbooks/05.kube-node.yml
...
部署network
#dk ezctl setup k8s-01 06
...
ansible-playbook -i clusters/k8s-01/hosts -e @clusters/k8s-01/config.yml playbooks/06.network.yml
...
安装其他应用插件
#dk ezctl setup k8s-01 07
...
ansible-playbook -i clusters/k8s-01/hosts -e @clusters/k8s-01/config.yml playbooks/07.cluster-addon.yml
...
配置kubectl
i. 配置/root/.kube/config
#从部机拷贝该文件 & 修改server配置
/etc/kubeasz/clusters/k8s-01/kubectl.kubeconfig
ii.配置系统PATH
#vim /etc/profile
...
export PATH=/opt/kube/bin/:$PATH
...
iii.测试下
#kubectl cluster-info
Kubernetes control plane is running at https://10.x.1.213:6443
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
参考
kubeasz/docs/setup/00-planning_and_overall_intro.md at master · easzlab/kubeasz · GitHub
更多推荐
已为社区贡献2条内容
所有评论(0)