官方文档:
k8s.sh可执行文件:
#!/bin/sh
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes Repository
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
EOF
# Set SELinux in permissive mode (effectively disabling it)
# 通过运行setenforce 0并sed ...有效禁用SELinux,将其设置为许可模式。这是允许容器访问主机文件系统所必需的,例如Pod网络所需要的。您必须执行此操作,直到kubelet中的SELinux支持得到改善。
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
# --now 与 enable 命令连用时, 表示同时还要启动该单元
systemctl enable --now kubelet
# -----------------------------------------------------------------------------------
# RHEL / CentOS 7上的一些用户报告了由于绕过iptables而导致流量无法正确路由的问题。您应该确保 net.bridge.bridge-nf-call-iptables在sysctl配置中将其设置为1
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system