所有节点执行
1、安装docker
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.reposudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
systemctl start docker
systemctl enable docker
docker ps
2、配置阿里云yum源
配置yum可以下载kubeadm、kubectl、kubelet
cat > /etc/yum.repos.d/kubernetes.repo << EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
安装 kubelet-1.23.6 kubeadm-1.23.6 kubectl-1.23.6
yum install -y kubelet-1.23.6 kubeadm-1.23.6 kubectl-1.23.6systemctl enable kubelet#配置docker 准备部署master
[root@k8s-master ~]# cat /etc/docker/daemon.json
{"exec-opts": ["native.cgroupdriver=systemd"],"registry-mirrors": ["https://kn0t2bca.mirror.aliyuncs.com"]
}[root@k8s-master ~]# systemctl daemon-reload
[root@k8s-master ~]# systemctl restart docker#修改前
[root@k8s-master ~]# docker info |grep DriverStorage Driver: overlay2Logging Driver: json-fileCgroup Driver: cgroupfs#修改后
[root@k8s-master ~]# docker info |grep DriverStorage Driver: overlay2Logging Driver: json-fileCgroup Driver: systemd
在master环境执行
配置master环境服务
kubeadm init \--apiserver-advertise-address=192.168.113.120 \ --image-repository registry.aliyuncs.com/google_containers \--kubernetes-version v1.23.6 \--service-cidr=10.96.0.0/12 \--pod-network-cidr=10.244.0.0/16
1、指定apiserver服务的地址
2、镜像仓库
3、k8s版本
4、servic网段
5、pod的网段
执行后出现successfully 成功按照提示执行
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
验证
[root@k8s-master ~]# kubectl get pod
No resources found in default namespace.
[root@k8s-master ~]# kubectl get node
NAME STATUS ROLES AGE VERSION
k8s-master NotReady control-plane,master 5m42s v1.23.6
node1、node2、环境部署地址
http://t.csdn.cn/t52hX