设置hosts文件
vim /etc/hosts
10.211.55.28 master
10.211.55.29 node1
10.211.55.30 node2
关闭swap
swapoff -a
sed -i '/swap/s/^/#/' /etc/fstab
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
sed -i 's/^ *SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
getenforce
如果你之前安装过 docker,请先删掉
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
安装一些依赖
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
下载repo文件
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
把软件仓库地址替换为 TUNA:
sudo sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo
安装docker
sudo yum makecache fast
sudo yum install docker-ce
sudo systemctl restart docker
修改加速和cgroupdriver
cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com",
"https://reg-mirror.qiniu.com",
"https://registry.docker-cn.com"
]
,
"exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
systemctl restart docker
验证修改是否成功
# docker info | grep Cgroup
Cgroup Driver: systemd
Cgroup Version: 1
设置kubernetes yum
[# cat /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=kubernetes
baseurl=https://mirrors.tuna.tsinghua.edu.cn/kubernetes/yum/repos/kubernetes-el7-$basearch
enabled=1
gpgcheck=0
yum -y install kubeadm kubelet kubectl ipvsadm
安装cri-dockerd
# wget https://github.com/Mirantis/cri-dockerd/releases/download/v0.2.6/cri-dockerd-0.2.6-3.el7.x86_64.rpm
# rpm -ivh cri-dockerd-0.2.6-3.el7.x86_64.rpm
# vim /lib/systemd/system/cri-docker.service
ExecStart=/usr/bin/cri-dockerd --container-runtime-endpoint fd:// --pod-infra-container-image registry.aliyuncs.com/google_containers/pause:3.7
#systemctl daemon-reload && systemctl restart cri-docker.service
初始化集群
kubeadm init --kubernetes-version=1.25.2 \
--apiserver-advertise-address=10.211.55.200 \
--image-repository registry.aliyuncs.com/google_containers \
--service-cidr=10.96.0.0/12 \
--pod-network-cidr=10.244.0.0/16 --cri-socket unix:///run/cri-dockerd.sock
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
在node1和node2执行,将node1和node2添加到集群中
kubeadm join 10.211.55.28:6443 --token nc6tnd.f7pc54aq89n82iwv --discovery-token-ca-cert-hash sha256:9dc0f880f71e76a4ecfb3b9b6dfded3d6d5b8e1bc48eea0ea890409b27d8cc41 --cri-socket unix:///run/cri-dockerd.sock
设置环境
# cat >> /etc/sysctl.conf <<eof
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
vm.swappiness=0
eof
# sysctl -p
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
vm.swappiness = 0
当多次调整都不成功的时候,可以重新获取一下token
kubeadm token create --print-join-command
安装calico
https://www.cnblogs.com/zyyang1993/p/16589895.html
标签:kubernetes,--,etc,yum,docker,cri,安装,1.25 From: https://www.cnblogs.com/zyyang1993/p/16732295.html