Kubernetes集群ezdown脚本一键部署

1585364631
2023-03-19 / 0 评论 / 262 阅读 / 正在检测是否收录...

Kubernetes集群ezdown脚本一键部署

1.环境准备

  • 主机信息
主机名IP地址集群服务
node110.107.24.81nodeetcd、api-server、controlor-manager、scheduler
node210.107.24.82nodekubelet、kube-proxy、docker
master10.107.24.83masterkubelet、kube-proxy、docker
  • 配置hosts解析
10.107.24.81 node1
10.107.24.82 node2
10.107.24.83 master
  • 生成SSH身份文件
ssh-keygen
一路回车
  • 配置免密登入
ssh-copy-id -i node1
ssh-copy-id -i node2
ssh-copy-id -i master
  • 测试免密登入
ssh master
ssh node1
ssh node2
  • 禁用交换分区
swapoff -a
sed -i.bak '/swap/s/^/#/' /etc/fstab
  • 关闭防火墙
systemctl stop firewalld && systemctl disable firewalld
  • 安装git和wget
yum install -y git wget

2.脚本安装Kubernetes

  • 下载ezdown
[root@master ~]# wget https://github.com/easzlab/kubeasz/releases/download/3.5.2/ezdown
[root@master ~]# chmod +x ezdown
  • 下载所需文件
# 国内
[root@master ~]# ./ezdown -D
# 国外
[root@master ~]# ./ezdown -D -m standard
2023-03-19 14:19:49 INFO Action successed: download_all
  • 创建集群配置
[root@master ~]# ./ezdown -S
2023-03-19 14:20:13 INFO Action begin: start_kubeasz_docker
2023-03-19 14:20:13 INFO try to run kubeasz in a container
2023-03-19 14:20:13 DEBUG get host IP: 10.107.24.83
fc0377122adc8726397e25b6f0285e04072e6b76b9f6b9bd1a0dca3b17d6e1a2
2023-03-19 14:20:14 INFO Action successed: start_kubeasz_docker
  • 创建新的集群
[root@master ~]# docker exec -it kubeasz ezctl new k8s
2023-03-19 06:21:22 DEBUG generate custom cluster files in /etc/kubeasz/clusters/k8s
2023-03-19 06:21:22 DEBUG set versions
2023-03-19 06:21:22 DEBUG cluster k8s: files successfully created.
2023-03-19 06:21:22 INFO next steps 1: to config '/etc/kubeasz/clusters/k8s/hosts'
2023-03-19 06:21:22 INFO next steps 2: to config '/etc/kubeasz/clusters/k8s/config.yml'
  • 修改新的集群配置文件
[root@master ~]# vim /etc/kubeasz/clusters/k8s/hosts
# 'etcd' cluster should have odd member(s) (1,3,5,...)
[etcd]
10.107.24.83

# master node(s), set unique 'k8s_nodename' for each node
# CAUTION: 'k8s_nodename' must consist of lower case alphanumeric characters, '-' or '.',
# and must start and end with an alphanumeric character
[kube_master]
10.107.24.83 k8s_nodename='master'

# work node(s), set unique 'k8s_nodename' for each node
# CAUTION: 'k8s_nodename' must consist of lower case alphanumeric characters, '-' or '.',
# and must start and end with an alphanumeric character
[kube_node]
10.107.24.81 k8s_nodename='node1'
10.107.24.82 k8s_nodename='node2'
  • 一键安装
docker exec -it kubeasz ezctl setup k8s all
PLAY RECAP *****************************************************************************************************
10.107.24.81               : ok=76   changed=73   unreachable=0    failed=0    skipped=129  rescued=0    ignored=1   
10.107.24.82               : ok=76   changed=73   unreachable=0    failed=0    skipped=129  rescued=0    ignored=1   
10.107.24.83               : ok=113  changed=105  unreachable=0    failed=0    skipped=152  rescued=0    ignored=1   
localhost                  : ok=43   changed=40   unreachable=0    failed=0    skipped=42   rescued=0    ignored=0   
0

评论 (0)

取消