k8S安装部署教程
要求 :三台虚拟机
以下步骤在三台虚拟机上均要执行
检查虚拟机内核版本
uname -r
关闭SELinux
检查SELinux状态,enabled为开启状态
/usr/sbin/sestatus -v
或者使用getenforce命令查看:
getenforce
关闭SELinux,修改配置文件,将SELINUX设置为disabled,并且修改SELinux模式为Premissive
setenforce 0 && sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
或者修改配置文件,将SELINUX设置为disabled,然后重启虚拟机生效
vim /etc/selinux/config
关闭防火墙
systemctl stop firewalld
关闭防火墙开机自启动
systemctl disable firewalld
检查防火墙状态,inactive为关闭状态,active为运行状态
systemctl status firewalld
安装依赖包
yum install -y conntrack ntpdate ntp ipvsadm ipset jq iptables curl sysstat libseccomp wget vim net-tools git
设置防火墙为iptables并设置空规则
yum -y install iptables-services && systemctl start iptables && systemctl enable iptables && iptables -F && service iptables save
永久关闭虚拟内存
swapoff -a && sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
调整内核参数,写入配置文件中
在/etc/sysctl.d/目录下创建kubernetes.conf文件,写入配置数据:
vim /etc/sysctl.d/kubernetes.conf
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
vm.swappiness=0
vm.overcommit_memory=1
vm.panic_on_oom=0
fs.inotify.max_user_instances=8192
fs.inotify.max_user_watches=1048576
fs.file-max=52706963
fs.nr_open=52706963
net.ipv6.conf.all.disable_ipv6=1
net.netfilter.nf_conntrack_max=2310720
保存退出后刷新配置立马生效
sysctl -p /etc/sysctl.d/kubernetes.conf
关闭系统不需要的服务
systemctl stop postfix && systemctl disable postfix
</