1、修改主机名
hostnamectl set-hostname k8s-master
2、添加主机名
cat >> /etc/hosts << EOF
192.168.60.136 k8s-master
192.168.60.137 k8s-node1
192.168.60.138 k8s-node2
EOF
3、关闭防火墙
systemctl stop firewalld && systemctl disable firewalld
systemctl status firewalld
4、关闭selinux
# 临时允许
setenforce 0
getenforce
# 永久允许
sed -i "s/SELINUX=enforcing/SELINUX=permissive/g" /etc/selinux/config
cat /etc/selinux/config
5、关闭swap分区
# 参考链接:https://www.cnblogs.com/architectforest/p/12982886.html
# 查看swapoff的版本
swapoff --version
# 临时关闭
swapoff -a
# 永久关闭
sed -ri 's/.*swap.*/#&/' /etc/fstab # 重启生效
# 使用swapon检查
swapon -v #输出为空,表示swap已关闭
# 使用free命令检查
free -m
# 重新启动swap分区
swapon -a
6、配置网卡联网
cat /etc/sysconfig/network-scripts/ifcfg-ens32
7、配置阿里云镜像
cd /etc/yum.repos.d/ && mkdir bak && mv CentOS-* bak/
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
8、生成本地缓存
yum makecache fast
9、更新YUM源软件包
yum update -y
10、将桥接的 IPv4 流量传递到 iptables 的链
cat >> /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
# cat /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
[root@k8s-master ~]#
11、设置主机之间时间同步
yum install -y ntpdate
ntpdate time.windows.com