从error中信息提示可以获知,需要关闭swap分区,命令为:

swapoff –a

将提示信息保存到一个文件中(名字随意,本文取得是K8sDebug.txt),使用awk、grep、cut等命令过滤出需要的镜像版本,命令如下:

awk -F" " '{print $7}' K8sDebug.txt | grep -v "^$" | grep -v "connection" |grep -v "fatal"| cut -d ":" -f 1,2

获取结果如下:

图中标亮的为需要的镜像版本,需要依据镜像版本替换成国内的源,将上述高亮的版本信息存放到另一个文件中(K8sDebug2.sh),批量替换源地址,将k8s.gcr.io替换成registry.aliyuncs.com/google_containers命令如下:

sed -i 's/k8s.gcr.io/registry.aliyuncs.com\/google_containers/g'  K8sDebug2.sh

结果如下:

依据已经替换的结果拉取对应的镜像,命令如下:

for i in `cat K8sDebug2.sh`;do docker pull $i;done

查看镜像:

对拉取的镜像重新打tag,变成k8s.gcr.io/格式,脚本为K8sDebug3.sh,如下所示:

#!/bin/bash
docker tag registry.aliyuncs.com/google_containers/kube-apiserver:v1.15.3 k8s.gcr.io/kube-apiserver:v1.15.3
docker tag registry.aliyuncs.com/google_containers/kube-controller-manager:v1.15.3 k8s.gcr.io/kube-controller-manager:v1.15.3
docker tag registry.aliyuncs.com/google_containers/kube-scheduler:v1.15.3 k8s.gcr.io/kube-scheduler:v1.15.3
docker tag registry.aliyuncs.com/google_containers/kube-proxy:v1.15.3 k8s.gcr.io/kube-proxy:v1.15.3
docker tag registry.aliyuncs.com/google_containers/pause:3.1 k8s.gcr.io/pause:3.1
docker tag registry.aliyuncs.com/google_containers/etcd:3.3.10 k8s.gcr.io/etcd:3.3.10
docker tag registry.aliyuncs.com/google_containers/coredns:1.3.1 k8s.gcr.io/coredns:1.3.1

 并删除registry.aliyuncs.com/google_containers/*系列镜像,命令如下:

for i in `cat K8sDebug2.sh`;do docker rmi $i;done

 

 重新执行命令:

 kubeadm init --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=NumCPU

 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐