master节点安装:
yum upgrade -y 更新系统
yum update -y 升级内核
ifconfig ens33
关闭swap
swapoff -a (临时)
vim /etc/fstab (永久)
#/dev/mapper/cl-swap swap swap defaults 0 0
vim /etc/sysctl.conf
vm.swappiness = 0
net.bridge.bridge-nf-call-arptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
lsmod |grep br_netfilter
modprobe br_netfilter
lsmod |grep br_netfilter
sysctl -p
systemctl disable firewalld.service && systemctl stop firewalld.service
安装docker 最新的docker兼容k8s,会报警 选择docker-ce-19.03.15
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum makecache fast
sudo yum list docker-ce --showduplicates | sort -r
sudo yum install docker-ce-19.03.15 -y
sudo systemctl enable docker
sudo systemctl start docker
安装kubernetes
(1)配置kuberbetes源
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
(2)关闭 selinux
setenforce 0
# cat /etc/selinux/config
# disabled - No SELinux policy is loaded.
SELINUX=disabled
(3)安装
yum install kubeadm kubelet kubectl -y
systemctl enable kubelet.service
(4)导入镜像并初始化
kubeadm init --kubernetes-version=v1.21.1 --apiserver-advertise-address 192.168.0.10 --pod-network-cidr 10.244.0.0/16
(5)下载配置文件
wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
docker pull quay.io/coreos/flannel:v0.14.0
(6)根据初始化成功的提示创建目录
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config