K8S安装
需要注意的是如果没有特殊说明,各个节点都需要步骤操作
环境准备
1.配置主机名
hostnamectl set-hostname master # master节点
hostnamectl set-hostname node1 # node1节点
hostnamectl set-hostname node2 # node2节点
2.配置hosts文件
每个节点配置相同
vim /etc/hosts
10.0.0.138 master m
10.0.0.143 node1 n1
10.0.0.139 node2 n2
3.安装依赖包
yum install -y conntrack ntpdate ntp ipvsadm ipset iptables curl sysstat libseccomp wget vim net-tools git
4.清空防火墙和SELinux
systemctl stop firewalld && systemctl disable firewalld # 关闭firewalld防火墙
yum -y install iptables-services && systemctl start iptables && systemctl enable iptables && iptables -F && service iptables save # 安装iptables并清空规则
setenforce 0 && sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config # 关闭SELinux
5.关闭交换分区
防止容器运行在swap空间里
swapoff -a && sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
free -h # 查看swap分区是否关闭成功
6.调整内核参数
# 开机会调用
cat > /etc/sysctl.d/kubernetes.conf <<EOF
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1 # 开启网桥模式
net.ipv4.ip_forward=1
net.ipv4.tcp_tw_recycle=0
net.ipv6.conf.all.disable_ipv6=1 # 关闭ipv6的协议
vm.swappiness=0 # 禁止使用 swap 空间,只有当系统 OOM 时才允许使用它
vm.overcommit_memory=1 # 不检查物理内存是否够用
v