新增kubeadm yum 源
cat << EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes Repo
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
查看要打包的版本,我以1.18.8版本为例
yum list --showduplicates | grep 'kubeadm\|kubectl\|kubelet' |grep 1.18.8
将所需的安装包离线下载至本地
yum -y install kubelet-1.18.8 kubectl-1.18.8 kubeadm-1.18.8 --downloadonly --downloaddir=./
安装离线包
yum localinstall -y ./*.rpm
查看需要的镜像
kubeadm config images list
可配置设置拉取k8s的源
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
也可以提前离线下载好,传到私有仓库
kubeadm init --kubernetes-version=1.18.8 --apiserver-advertise-address=172.17.0.10 --image-repository registry.aliyuncs.com/google_containers --service-cidr=10.1.0.0/16 --pod-network-cidr=10.222.0.0/16