[Posts] domestic pull taken image google kubernetes

Domestic pulling google kubernetes mirror

Disclaimer: This article is a blogger original article, please indicate the source. HTTPS: // blog.csdn.net/networken/article/details/84571373 

thanks to the original author.

 

Foreword

Mirroring the domestic warehouse accessible
Docker Hub mirror warehouse
https://hub.docker.com/
Ali cloud mirror repository:
https://cr.console.aliyun.com
RedHat mirror warehouse:
https://access.redhat.com/ containers

Domestic inaccessible Mirror warehouse
google image warehouse:
https://console.cloud.google.com/gcr/images/google-containers/GLOBAL
CoreOS Mirror warehouse:
https://quay.io/repository/

Workaround:

  1. When deploying kubernetes cluster, you need to get from google image warehouse kubernetes components related to the mirror, and obtain flannel network plug-ins image from coreos warehouse, but dockerhub or Ali cloud warehouse basically be able to search other people uploaded contains these two warehouses in the mirror, we just need to pull back to the future to the local default image tag can be.
  2. In addition dockerhub on google warehouse are mirrored mirror, so you can add mirrorgooglecontainers before google image name, you can take the google image directly dockerhub pull, pull to a local warehouse after the same change back to the default tag can google.

E.g. pulling kube-apiserver-amd64: v1.13.2 image to use the following format:

Mirror # google default format 
k8s.gcr.io / Kube-apiserver:. V1 13.2 
# dockerhub pulling mirror 
$ Docker pull mirrorgooglecontainers / Kube-apiserver-AMD64:. V1 13.2 
# modify Tag 
$ Docker Tag mirrorgooglecontainers / Kube-apiserver-AMD64 :. v1 13.2 . k8s.gcr.io/kube-apiserver-amd64:v1 13.2 
# successfully pull mirroring 
$ Docker ImagesRF Royalty Free | grep kube- apiserver 
mirrorgooglecontainers . / Kube-apiserver AMD64-v1 13.2              177db4b8e93a         2 months ago Member 181MB 
K8S. gcr.io / AMD64 Kube-apiserver-V1. 13.2              177db4b8e93a        2 months ago        181MB

 

Ali cloud images from the warehouse search and pull

# Pull Mirror Mirror from Ali cloud repository 
$ Docker pull registry.cn -hangzhou.aliyuncs.com/google_containers/kube-apiserver-amd64:v1. 13.0 
# modify mirroring Tag 
$ Docker Tag registry.cn -hangzhou.aliyuncs.com/ google_containers / Kube-apiserver-AMD64:. V1 13.0 . k8s.gcr.io/kube-apiserver:v1 13.0

 

Create a personal warehouse

We can also create a personal cloud in dockerhub or Ali warehouse need the latest version of the image from google repository to push individual warehouses, generally there are a few ways:
1. Purchase a cloud server
the easiest way is to buy a station can simultaneously access to foreign and domestic network cloud server, or using a docker login Login dockerhub Ali cloud warehouse, docker push command push up and then pulled to a local can.
If you do not want to buy a server and access to foreign networks, it is recommended to use cloud shell google offer:
https://console.cloud.google.com/cloudshell
It is similar to a permanent owner free 5G storage space linux server, you can perform all docker command and bash command, can access the global network.

2.Travis CI push mirroring
use travis CI + GitHub will mirror mirror docker push to domestic warehouse.

3.Github mirror constructed
using github of dockerfile build features that will be mirrored to build domestic warehouse.
Reference: https://blog.csdn.net/networken/article/details/85215714

Travis CI push dokcer mirror

The following describes the second method, using a method travis CI + GitHub to pull the mirror aliyun or dockehub.

Create a github repository
login first create a github repository, custom name, warehouse contains the following three files:

  • push-images.sh  script file
  • imagepath.txt mirror list file
  • .travis.yaml automatically build file

Example warehouse: https://github.com/willzhang/DockerImages

push-images.sh script reads as follows, mainly from abroad Mirror Mirror warehouse pull, playing tag, and push to Ali cloud or dockerhub.

#!/bin/bash

for imagepath in $(cat ./imagepath.txt)
do
imagename=$(echo $imagepath | awk -F '/' '{print $NF}')
docker pull $imagepath

# push到阿里云仓库
docker tag $imagepath registry.cn-hangzhou.aliyuncs.com/aliwill/$imagename
docker push registry.cn-hangzhou.aliyuncs.com/aliwill/$imagename

# push到dockerhub
docker tag $imagepath willdockerhub/$imagename
docker push willdockerhub/$imagename
done

 

imagepath.txt contains a list of the main mirror of the country can not be pulled, must pay attention to the full path and name of the mirror, for example:

gcr.io/google-containers/kube-apiserver-amd64:v1.12.0
quay.io/external_storage/nfs-client-provisioner:latest

  

.travis.yaml documents mainly monitor code changes github repository, such as when there are changes in the code when writing new imagepath.txt mirror list will trigger automatic construction of tarvis, .travis.yaml document reads as follows:

language: bash

services:
- docker

script:
- docker login -u $ALI_USERNAME registry.cn-hangzhou.aliyuncs.com -p $ALI_PASSWORD
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- bash push-images.sh

 

 

Ali cloud here need to log in or dockerhub to perform docker push operations, which can be good $ ALI_USERNAME such variable is defined in TravisCI management interface.

TravisCI Configuration

Travis visit the official website:  , https://www.travis-ci.org/  use github account login.

Open to the need for warehouse automation built:
Here Insert Picture Description
Also you need to click on the upper right corner more options - "settings option, defined in .travis.yaml write the account password and other sensitive parameters.
Here Insert Picture Description
When performing git commit to github repository, git push operation will automatically trigger a build, script execution warehouse building where results are as follows:
Here Insert Picture Description
Log Ali cloud or dockerhub view, imagepath.txt list image has been successfully push up:
Note : push to Ali cloud mirrored private by default, you can manually change disclosure.
Here Insert Picture Description
Here Insert Picture Description
Daily Mirror pull method:
Modify imagepath.txt, write the full path of the mirror is necessary to pull after saving travis-CI monitor changes in the code to the warehouse, automatically triggered to build, after a few minutes the mirror will be automatically pulled into the individual warehouse.

Reference:
https://blog.csdn.net/nklinsirui/article/details/80581286

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/11320485.html