1.26版本kubeadm安装k8s
提前准备:内核选择。
最低要求3.10. 个人建议上4.5以后的版本。
(k8s开启ipvs模式最低要求4.1内核)
yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm -y
sed -i "s@mirrorlist@#mirrorlist@g" /etc/yum.repos.d/elrepo.repo
sed -i "s@elrepo.org/linux@mirrors.tuna.tsinghua.edu.cn/elrepo@g" /etc/yum.repos.d/elrepo.repo
升级稳定ml内核
yum -y --enablerepo=elrepo-kernel install kernel-ml
配置默认内核
grubby --default-kernel
grubby --set-default $(ls /boot/vmlinuz-* | grep elrepo)
reboot重启
一,环境注意事项
1.0 可选:更换yum源 http://mirrors.aliyun.com/repo/
1.1 主机名更改 vi /etc/hostname
1.2 vhosts文件 vi /etc/hosts
1.3 关闭本身自带的selinux setenforce 0 sed -i 's/enforcing/disabled/' /etc/selinux/config
1.4 关闭firewalld防火墙 systemctl stop firewalld systemctl disable firewalld
1.5 修改文件句柄数/最大进程数
vi /etc/security/limits.conf
soft nofile 655360
hard nofile 655360
soft nproc 655350
hard nproc 655350
seft memlock unlimited
hard memlock unlimited
1.6 关闭交换分区
swapoff -a
vi /etc/fstab
1.7配置静态地址
vi /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.112.100
#跟你虚拟NAT网卡一个网段,我们后面要联网
NETMASK=255.255.255.0
GATEWAY=192.168.112.2
DNS1=192.168.112.2
1.8 开启桥接流量外部介入
[root@master01 ~]# cat /etc/sysctl.d/k8s.conf
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
fs.may_detach_mounts = 1
vm.overcommit_memory=1
vm.panic_on_oom=0
fs.inotify.max_user_watches=89100
fs.file-max=52706963
fs.nr_open=52706963
net.netfilter.nf_conntrack_max=2310720
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl =15
net.ipv4.tcp_max_tw_buckets = 36000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_max_orphans = 327680
net.ipv4.tcp_orphan_retries = 3
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.ip_conntrack_max = 65536
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_timestamps = 0
net.core.somaxconn = 16384
vm.swappiness=0
sysctl --system 1.9
#可选开启ipvs模式,性能更高,默认是走iptables。
yum -y install ipvsadm ipset 安装完等一会就可以了
lsmod | grep ip_vs 查看是否已经启用了ipvs,如果未显示,可手动添加。
cat > /etc/sysconfig/modules/ipvs.modules << EOF #!/bin/bash modprobe -- ip_vs modprobe -- ip_vs_rr modprobe -- ip_vs_wrr modprobe -- ip_vs_sh modprobe -- nf_conntrack_ipv4
#centos8以上用nf_conntrack EOF chmod 755 /etc/sysconfig/modules/ipvs.modules source /etc/sysconfig/modules/ipvs.modules
后面用于kube-proxy的配置更改。
kubectl edit -n kube-system cm kube-proxy mode: "ipvs" 1.10,
时间同步 ntpdate time.windows.com
1.11 重启生效检验 rebooot