一、环境说明
采用三台主机部署,其中1台master,2台node,因为资源比较不足,所以配置也比较低,目前按照2C\2G\40G的配置来的。
主机名 | IP地址 |
k8s-master | 192.168.186.111 |
k8s-node1 | 192.168.186.112 |
k8s-node2 | 192.168.186.113 |
二、系统初始化
1. 配置hosts
修改所有主机hosts,把每台主机IP和主机名对应关系写入host文件
#执行三条命令
echo "192.168.186.111 k8s-master" >> /etc/hosts
echo "192.168.186.112 k8s-node1" >> /etc/hosts
echo "192.168.186.113 k8s-node2" >> /etc/hosts
检查确认下:
root@k8s-node2:~# cat /etc/hosts
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.186.111 k8s-master
192.168.186.112 k8s-node1
192.168.186.113 k8s-node2
2. 关闭防火墙
sudo systemctl status ufw.service
sudo systemctl stop ufw.service
sudo systemctl disable ufw.service
3. 关闭swap:
systemctl stop swap.target
systemctl disable swap.target
systemctl status swap.target
systemctl stop swap.img.swap
systemctl status swap.img.swap
vim /etc/fstab
#把/swap.img开头的这一行注释掉,同时修改swap挂在为sw,noauto,如下所以:
cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/disk/by-uuid/fb8812a4-bbb4-4ab4-a0a6-5dcdc103c2fc none swap sw,noauto 0 0
# / was on /dev/sda4 during curtin installation
/dev/disk/by-uuid/f797ac9a-ece0-4fae-af84-cc3ec41d0419 / ext4 defaults 0 1
# /boot was on /dev/sda2 during curtin installation
/dev/disk/by-uuid/3e71e4e2-538e-4340-9239-eef1675baa0d /boot ext4 defaults 0 1
#/swap.img none swap sw 0 0
完成之后,重启系统,使用free -m检查一下是否禁用成功,如下就是禁用成功: