2020-k8s(一)安装k8s集群
主机初始化
安装常用组件包
yum install epel-release -y
yum -y install conntrack netdate ntp ipvsadm ipset jq iptables curl sysstat wget vim git libseccomp net-tools
jq 类似 python -m json.tools
关闭防火墙
systemctl stop firewalld && systemctl disable firewalld
yum install iptables-services -y
systemctl start iptables && systemctl enable iptables
iptables -F
service iptables save
关闭 selinux
vi /etc/selinux/config
将SELINUX=enforcing改为SELINUX=disabled
设置后需要重启才能生效
reboot
升级内核
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
lt long-term 长期维护版本 ml 主线版本
yum --enablerepo=elrepo-kernel install kernel-lt
sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
grub2-set-default 0
grub2-mkconfig -o /boot/grub2/grub.cfg
安装docker ,配置 ip_vs 模块
[root@k8s-master ~]# cat /etc/sysconfig/modules/ipvs.sh
#!/bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack_ipv4
修改内核参数
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
docker 安装方式 参考 阿里云提供镜像
配置 log-driver 和 cgroup
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts" : ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts" : { "max-size" : "10m","max-file":"3" }
}
EOF
本文来自博客园,作者:萱乐庆foreverlove,转载请注明原文链接:https://www.cnblogs.com/leleyao/p/13288983.html

浙公网安备 33010602011771号