Problems and solutions encountered in K8s init initialization

You can know from the information in the error that the swap partition needs to be closed. The command is:

swapoff –a

Save the prompt information to a file (the name is arbitrary, this article is K8sDebug.txt), and use awk, grep, cut and other commands to filter out the required image version, the command is as follows:

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

The obtained results are as follows:

The image highlighted in the figure is the required image version, which needs to be replaced with the domestic source according to the image version, store the above highlighted version information in another file (K8sDebug2.sh), replace the source address in batches, and replace k8s.gcr.io with registry.aliyuncs.com/google_containers The command is as follows:

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

The result is as follows:

Pull the corresponding image according to the replaced result, the command is as follows:

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

Check out the mirror:

Re-tag the pulled image into k8s.gcr.io/ format, and the script is K8sDebug3.sh, as shown below:

#!/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

 And delete registry.aliyuncs.com/google_containers/* series images, the command is as follows:

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

 

 Re-execute the command:

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

 

Guess you like

Origin blog.csdn.net/IT_dreamer1993/article/details/101676863