设置系统主机名以及 Host 文件的相互解析
hostnamectl set-hostname k8s-master01
安装依赖包
yum install -y conntrack ntpdate ntp ipvsadm ipset iptables curl sysstat libseccomp wget vim net-tools git
设置防火墙为 Iptables 并设置空规则
systemctl stop firewalld && systemctl disable firewalld yum -y install iptables-services && systemctl start iptables && systemctl enable iptables && iptables -F && service iptables save
关闭 SELINUX
swapoff -a && sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab setenforce 0 && sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
调整内核参数,对于 K8S
cat > kubernetes.conf <<EOF net.bridge.bridge-nf-call-iptables=1 #在ipv4网络下所以经过网桥的流量都要经过防火墙的处理 net.bridge.bridge-nf-call-ip6tables=1 #在ipv6网络下所以经过网桥的流量都要经过防火墙的处理 net.ipv4.ip_forward=1 #开启数据包的路由转发功能 net.ipv4.tcp_tw_recycle=0 vm.swappiness=0 # 禁

该教程详细介绍了如何在 CentOS 7.x 上进行 Kubernetes(K8s)系统的初始化,包括设置主机名和Host文件解析、安装依赖、配置Iptables防火墙、禁用SELINUX、调整内核参数、设置时区、关闭不必要的服务、优化rsyslogd和systemd journald以及升级内核至4.44版本,以确保K8s环境的稳定运行。
最低0.47元/天 解锁文章

2204

被折叠的 条评论
为什么被折叠?



