# 检查内核版本(要求3.10+)
uname -r
# 检查系统架构和发行版
cat /etc/os-release
# 检查交换空间(生产环境应禁用)
free -h
推荐组合: - Ubuntu 20.04/22.04 LTS + K8S 1.24+ - CentOS/RHEL 8/9 + K8S 1.24+ - Flatcar Container Linux + K8S 1.24+
# 对于containerd
cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter
# 配置内核参数
cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF
sudo sysctl --system
# 禁用防火墙(仅测试环境)
sudo systemctl stop firewalld
sudo systemctl disable firewalld
# 或配置防火墙规则放行K8S流量
sudo firewall-cmd --permanent --add-port=6443/tcp
sudo firewall-cmd --permanent --add-port=10250/tcp
sudo firewall-cmd --reload
使用官方支持的组合:参考K8S官方文档的"Supported Operating Systems"部分
保持系统更新:
# Ubuntu/Debian
sudo apt update && sudo apt upgrade -y
# RHEL/CentOS
sudo yum update -y
使用工具验证环境:
# 使用kubeadm预检工具
sudo kubeadm init phase preflight
考虑使用容器优化的Linux发行版:
日志排查:
# 查看kubelet日志
journalctl -u kubelet -f
# 查看容器运行时日志
journalctl -u containerd -f
通过以上方法,可以解决大多数Linux与Kubernetes的安装兼容性问题。如遇特定问题,建议查阅K8S官方文档或相关发行版的K8S支持文档。