k8s官方:https://kuboard.cn/
一、配置要求
- 至少 2 台 2核4G 的服务器
- 硬盘:30G以上(包括30)
- 版本:centos7.9
- CPU 必须为 x86 架构
查看版本命令
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
查看cpu命令
lscpu
二、环境准备(主从都要执行)
- 检查 centos / hostname
- 检查网络
- 关闭防火墙
- 关闭selinux
- 关闭swap
- 修改内核参数
2.1检查 centos / hostname
不能使用 localhost 作为节点的名字
master
# 修改 hostname
hostnamectl set-hostname master.local
node
# 修改 hostname
hostnamectl set-hostname node.local
修改本地/etc/hosts文件
#vi /etc/hosts
192.168.1.129 master.local
192.168.1.130 node.local
2.2检查网络
是裸机更好 朋友们,网卡就一张环回网卡,加本地网卡就行。
2.3关闭防火墙
所有节点上 Kubernetes 所使用的 IP 地址必须可以互通
systemctl stop firewalld && systemctl disable firewalld && iptables -F
2.4关闭selinux
sed -i 's/enforcing/disabled/' /etc/selinux/config && setenforce 0
2.5关闭swap
临时关闭
swapoff -a
永久关闭swap
sed -ri 's/.*swap.*/#&/' /etc/fstab
2.6修改内核参数
cat > /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
sysctl --system
加载ip_vs内核模块
如果kube-proxy 模式为ip_vs则必须加载
modprobe ip_vs
modprobe ip_vs_rr
modprobe ip_vs_wrr
modprobe ip_vs_sh
modprobe nf_conntrack_ipv4
设置下次开机自动加载
cat > /etc/modules-load.d/ip_vs.conf << EOF
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
nf_conntrack_ipv4
EOF
三、安装docker及kubelet
- 安装doker
- 初始化 master 节点
- 初始化 worker节点
- 检查初始化结果
请认真核对如下选项,7 个都选中后才能显示如何安装
我的任意节点 centos 版本为 7