当前位置:首页 > Web开发 > 正文

kubernetes v1.14.0版本集群搭建(centos7)

2024-03-31 Web开发

一.主机环境配置(centos7.6)

1.主机名设置

1 #所有主机分别设置如下 2 # hostnamectl set-hostname master 3 # hostnamectl set-hostname node1 4 # hostnamectl set-hostname node2

2.主机名绑定hosts

#所有主机设置相同 # cat /etc/hosts ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ? 192.168.11.111 master 192.168.11.112 node1 192.168.11.113 node2

3.静态ip设置

# cat /etc/sysconfig/network-scripts/ifcfg-eth0 TYPE="Ethernet" BOOTPROTO="static" NAME="eth0" DEVICE="eth0" ONBOOT="yes" IPADDR="192.168.11.111" PREFIX="24" GATEWAY="192.168.11.253" ? # cat /etc/sysconfig/network-scripts/ifcfg-eth0 TYPE="Ethernet" BOOTPROTO="static" NAME="eth0" DEVICE="eth0" ONBOOT="yes" IPADDR="192.168.11.112" PREFIX="24" GATEWAY="192.168.11.253" ? # cat /etc/sysconfig/network-scripts/ifcfg-eth0 TYPE="Ethernet" BOOTPROTO="static" NAME="eth0" DEVICE="eth0" ONBOOT="yes" IPADDR="192.168.11.113" PREFIX="24" GATEWAY="192.168.11.253" ? # 注意:阿里云ecs可以不用设置

4.selinux关闭 所有主机设置如下

# sed -ri s/SELINUX=enforcing/SELINUX=disabled/ /etc/selinux/config

设置完后重启生效
seleinux状态查看

[[email protected] ~]# sestatus SELinux status: disabled

5.ntp时间同步 所有主机设置时间同步

# ntpdate time1.aliyun.com

6.swap关闭 所有主机关闭swap
临时关闭swap命令如下

# swapoff -a

?
永久关闭

# cat /etc/fstable ... #/dev/mapper/centos-swap swap swap defaults 0 0
#注释上面一行即可

7.防火墙 所有主机配置防火墙
关闭firewalld

# systemctl disable firewalld # systemctl stop firewalld [[email protected] ~]# firewall-cmd --state not running [[email protected] ~]#


安装iptables并配置

# yum -i install iptables-services # systemctl enable iptables # systemctl stop iptables # iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X # iptables -P FORWARD ACCEPT # service iptables save

-F:删除指定表的所有链上的规则
-X:删除用户自定义的链
-P:修改链上的策略
不指定表的情况下默认是filter
8.网桥过滤 所有主机配置网桥过滤

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/41984.html