k8s系列-07-kubespray方案基础环境准备
主旨
hostname |
IP地址 |
角色 |
cpu |
memory |
node-1 |
192.168.112.130 | master |
>=2 |
>=2 |
node-2 |
192.168.112.131 | master |
>=2 |
>=2 |
node-3 |
192.168.112.132 | worker |
>=2 |
>=2 |
修改主机名
192.168.112.130 操作,操作完毕之后需要重新连接:
[yunweijia@localhost ~]$ sudo vim /etc/hostname
# 清空文件原内容,写入下面信息
node-1
[yunweijia@localhost ~]$ sudo hostname node-1
[yunweijia@localhost ~]$ bash
[yunweijia@node-1 ~]$
192.168.112.131 操作:
[yunweijia@localhost ~]$ sudo vim /etc/hostname
# 清空文件原内容,写入下面信息
node-2
[yunweijia@localhost ~]$ sudo hostname node-2
[yunweijia@localhost ~]$ bash
[yunweijia@node-2 ~]$
192.168.112.132 操作,操作完毕之后需要重新连接:
[yunweijia@localhost ~]$ sudo vim /etc/hostname
# 清空文件原内容,写入下面信息
node-3
[yunweijia@localhost ~]$ sudo hostname node-3
[yunweijia@localhost ~]$ bash
[yunweijia@node-3 ~]$
关闭安全策略
[yunweijia@node-1 ~]$ sudo systemctl stop firewalld.service
[yunweijia@node-1 ~]$ sudo systemctl disable firewalld.service
[yunweijia@node-1 ~]$ sudo setenforce 0
[yunweijia@node-1 ~]$ sudo vim /etc/selinux/config
SELINUX=enforcing # 该行注释掉,新建行内容如下:
SELINUX=disabled
[yunweijia@node-1 ~]$
[yunweijia@node-1 ~]$ su root
密码:
[root@node-1 yunweijia]# iptables -F && iptables -X && iptables -F -t nat && iptables -X -t nat && iptables -P FORWARD ACCEPT
[root@node-1 yunweijia]# exit
exit
[yunweijia@node-1 ~]$
[yunweijia@node-1 ~]$ sudo service dnsmasq stop
Redirecting to /bin/systemctl stop dnsmasq.service
[yunweijia@node-1 ~]$ sudo systemctl disable dnsmasq
[yunweijia@node-1 ~]$
以下步骤,要在所有的服务器上进行操作,操作内容一致,只写一遍了。
[yunweijia@node-1 ~]$ sudo vim /etc/sysctl.d/kubernetes.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.ip_forward = 1
vm.swappiness = 0
vm.overcommit_memory = 1
[yunweijia@node-1 ~]$ sudo sysctl -p /etc/sysctl.d/kubernetes.conf
[remove -y docker* ]$ sudo yum
[ ]$ sudo rm -f /etc/docker/daemon.json