集群构建
本实验参考:https://github.com/gjmzj/kubeasz
kubernetes官方github地址 https://github.com/kubernetes/kubernetes/releases
软硬件限制:
①cpu和内存 master:至少1c2g,推荐2c4g;node:至少1c2g
②linux系统 内核版本至少3.10,推荐CentOS7/RHEL7
③docker 至少1.9版本,推荐1.12+
④etcd 至少2.0版本,推荐3.0+
高可用集群所需节点规划:
①部署节点------x1 : 运行这份 ansible 脚本的节点
②etcd节点------x3 : 注意etcd集群必须是1,3,5,7...奇数个节点
③master节点----x2 : 根据实际集群规模可以增加节点数,需要额外规划一个master VIP(虚地址)
④lb节点--------x2 : 负载均衡节点两个,安装 haproxy+keepalived
⑤node节点------x3 : 真正应用负载的节点,根据需要提升机器配置和增加节点数
四台主机规划:
主机
主机名
集色角色
192.168.1.200
master
deploy、etcd、lb1、master1
192.168.1.201
master2
lb2、master2
192.168.1.202
node
etcd2、node1
192.168.1.203
node2
etcd3、node2
192.168.1.250
vip
一、准备工作
1:四台机器都执行安装epel源、更新、安装Python包。(说明:这边是为了做实验,,防止出现不必要错误,把防火墙关闭了,生成环境勿学)
1 yum install -y epel-release 2 yum install -y python 3 iptables -F 4 setenforce 0
【deploy节点操作】
2:安装ansible
1 [[email protected] ~]# yum -y install ansible
3:生成密钥对
1 [[email protected] ~]# ssh-keygen 2 Generating public/private rsa key pair. 3 Enter file in which to save the key (/root/.ssh/id_rsa): 4 Created directory ‘/root/.ssh‘. 5 Enter passphrase (empty for no passphrase): 6 Enter same passphrase again: 7 Your identification has been saved in /root/.ssh/id_rsa. 8 Your public key has been saved in /root/.ssh/id_rsa.pub. 9 The key fingerprint is: 10 SHA256:cfoSPSgeEkAkgY08UIVWK2t2eNJIrKph5wkRkZX7AKs [email protected] 11 The key‘s randomart image is: 12 +---[RSA 2048]----+ 13 |BOB=+ | 14 |oB=o . | 15 | oB + . . | 16 | +.O . * | 17 |o.B B o S o | 18 |Eo.+ + o o . | 19 |oo . . . . | 20 |o.+ . . | 21 |. o | 22 +----[SHA256]-----+
4:拷贝秘钥到四台机器中
1 [[email protected] ~]# for ip in 200 201 202 203; do ssh-copy-id 192.168.1.$ip; done
5:测试是否可以免密登录
1 [[email protected] ~]# ssh 192.168.1.200 2 Last login: Wed Dec 11 10:47:55 2019 from 192.168.1.2 3 [[email protected] ~]# exit 4 登出 5 Connection to 192.168.1.200 closed. 6 [[email protected] ~]# ssh 192.168.1.201 7 Last login: Wed Dec 11 10:48:00 2019 from 192.168.1.2 8 [[email protected] ~]# exit 9 登出 10 Connection to 192.168.1.201 closed. 11 [[email protected] ~]# ssh 192.168.1.202 12 Last login: Wed Dec 11 11:13:53 2019 from 192.168.1.200 13 [[email protected] ~]# exit 14 登出 15 Connection to 192.168.1.202 closed. 16 [[email protected] ~]# ssh 192.168.1.203 17 Last login: Wed Dec 11 10:48:20 2019 from 192.168.1.2 18 [[email protected] ~]# exit 19 登出 20 Connection to 192.168.1.203 closed.
6:下载脚本文件,安装kubeasz代码、二进制、离线镜像
脚本下载链接:https://pan.baidu.com/s/1GLoU9ntjUL2SP4R_Do7mlQ
提取码:96eg
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/40623.html