一 首先准备三个IP地址,分别作为master节点和两个node节点
master:192.168.243.4
node1:192.168.243.5
node2:192.168.243.6
二 修改主机名字
[root@localhost ~]# hostnamectl set-hostname master && bash //master节点
[root@localhost ~]# hostnamectl set-hostname node1 && bash //node1节点
[root@node1 ~]#
[root@loxalhost ~]# hostnamectl set-hostname node2 && bash //node2节点
[root@node2 ~]#
以下操作三台主机相同,
三 修改hosts文件
[root@master ~]# vim /etc/hosts
验证是否能够ping通,可以看到我的已经成功
[root@master ~]# ping 192.168.243.5
PING 192.168.243.5 (192.168.243.5) 56(84) bytes of data.
64 bytes from 192.168.243.5: icmp_seq=1 ttl=64 time=0.155 ms
64 bytes from 192.168.243.5: icmp_seq=2 ttl=64 time=0.159 ms
64 bytes from 192.168.243.5: icmp_seq=3 ttl=64 time=0.086 ms
64 bytes from 192.168.243.5: icmp_seq=4 ttl=64 time=0.066 ms
64 bytes from 192.168.243.5: icmp_seq=5 ttl=64 time=0.074 ms
64 bytes from 192.168.243.5: icmp_seq=6 ttl=64 time=0.100 ms
^Z
[1]+ 已停止 ping 192.168.243.5
[root@master ~]# ping 192.168.243.6
PING 192.168.243.6 (192.168.243.6) 56(84) bytes of data.
64 bytes from 192.168.243.6: icmp_seq=1 ttl=64 time=1.39 ms
64 bytes from 192.168.243.6: icmp_seq=2 ttl=64 time=0.593 ms
64 bytes from 192.168.243.6: icmp_seq=3 ttl=64 time=1.31 ms
^Z
[2]+ 已停止 ping 192.168.243.6
[root@master ~]#
四 关闭交换分区,可以看到我的已经成功了
[root@master ~]# swapoff -a //临时关闭
[root@master ~]# vim /etc/fstab //永久关闭
[root@master ~]# free -h
total used free shared buff/cache available
Mem: 3.6G 1.0G 1.8G 35M 779M 2.3G
Swap: 0B 0B 0B
[root@master ~]#
五 修改内核参数
加载br_netfilter模块
[root@master ~]# modprobe br_netfilter
[root@master ~]#
启动相应的内核参数
[root@master ~]# cat > /etc/sysctl.d/k8s.conf <<EOF
> net.bridge.bridge-nf-call-ip6tables = 1
> net.brid