preface

Build Kubespray recently, in the use of Kubernetes and docker will appear some mirror can not pull or slower, k8s. GCR. IO mirror more outrageous, science cannot pull, online sell similar to the following error message.

Fatal: [node1 -> 192.168.1.104]: FAILED! = > {" attempts ": 4," changed ": true," CMD ": ["/usr/bin/docker" and "pull", "k8s. GCR. IO/coredns: 1.7.0"], "delta" : "0:00:15. 116121", "end" : "the 2021-01-16 11:35:22. 398178", "invocation" : {" module_args ": {" _raw_params" : "/usr/bin/docker pull k8s.gcr. IO /coredns:1.7.0", "_uses_shell": false, "argv": null, "chdir": null, "creates": null, "executable": null, "removes": null, "stdin": null, "stdin_add_newline": true, "strip_empty_ends": true, "warn": True}}, "MSG ": "non-zero return code", "rc": 1, "start": "2021-01-16 11:35:07.282057", "stderr": "Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)", "stderr_lines": [ "Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)" ], "stdout": "", "stdout_lines": [] }Copy the code

We also found a lot of mirror sources online, many of which are invalid. Azure China’s mirror has failed, and USTC’s is not very stable.

So can only take the song in the way, using Ali cloud to build a mirror

Create ali Cloud image library

First enter ali cloud container image server

Creating a namespace

Tips: A maximum of three namespaces

Creating a Mirror library

The successful construction is shown as follows:

Add rules

Click Build Now

OK, at this point, the entire image is built

The image builds the Dockerfile

This is the address of my warehouse

For example, k8S-dnS-node-cache /Dockerfile only has the following simple line of code

The FROM k8s. GCR. IO/DNS/k8s - DNS - node - cache: 1.16.0Copy the code

Docker pulls the image

# pull mirror [root @ k8s - master k8s] $docker pull registry.cn-hangzhou.aliyuncs.com/owater/k8s-dns-node-cache:1.16.0 # image tag [root @ k8s - master k8s] $docker tag registry.cn-hangzhou.aliyuncs.com/owater/k8s-dns-node-cache:1.16.0 K8s. GCR. IO/DNS/k8s - DNS - node - cache: 1.16.0Copy the code

IO/DNS /k8s-dns-node-cache:1.16.0 k8s.gcr. IO/DNS /k8s-dns-node-cache:1.16.0