kubeadm部署K8S

部署二主二从

主1:192.168.116.17

主2:192.168.116.18

从1:192.168.116.12

从2:192.168.116.13

注意事项:

master节点的cpu核心数必须要求大于2

K8S最新版本并不一定是最好的,相对于旧版本,核心功能稳定,但是新增功能、接口相对不稳

宿主机尽量升级到centos7.9版本

内核kernel升级到4.19+这种稳定的内核

环境准备

//所有节点,关闭防火墙规则,关闭selinux,关闭swap交换
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/enforcing/disabled/' /etc/selinux/config
iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X
​
swapoff -a                      #交换分区必须要关闭
sed -ri 's/.*swap.*/#&/' /etc/fstab     #永久关闭swap分区,&符号在sed命令中代表上次匹配的结果
​
#加载 ip_vs 模块
for i in $(ls /usr/lib/modules/$(uname -r)/kernel/net/netfilter/ipvs|grep -o "^[^.]*");do echo $i; /sbin/modinfo -F filename $i >/dev/null 2>&1 && /sbin/modprobe $i;done
​
//修改主机名
hostnamectl set-hostname master01
hostnamectl set-hostname master02
hostnamectl set-hostname node01
hostnamectl set-hostname node02
​
//所有节点修改hosts文件
cat >> /etc/hosts << EOF
192.168.116.17 master01
192.168.116.18 master02
192.168.116.12 node01
192.168.116.13 node02
EOF
​
//调整内核参数
cat > /etc/sysctl.d/kubernetes.conf << EOF
#开启网桥模式,可将网桥的流量传递给iptables链
net.bridge.bridge-nf-call-ip6tables=1
net.bridge.bridge-nf-call-iptables=1
#关闭ipv6协议
net.ipv6.conf.all.disable_ipv6=1
net.ipv4.ip_forward=1
EOF
​
//生效参数
sysctl --system  
​
//时间同步
ntpdate ntp.aliyun.com

所有节点安装Docker

yum install -y yum-utils device-mapper-persistent-data lvm2
​
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值