镜像下载脚本
<h1>1.镜像下载命令</h1>
<pre><code class="language-bash">./rancher-save-images.sh --image-list ./rancher-images.txt</code></pre>
<h1>2.rancher-save-images.sh 内容</h1>
<pre><code class="language-bash">#!/bin/bash
## 如何执行:./rancher-save-images.sh --image-list ./rancher-images.txt
list="rancher-images.txt"
images="rancher-images.tar.gz"
usage () {
echo "USAGE: $0 [--image-list rancher-images.txt] [--images rancher-images.tar.gz]"
echo " [-l|--image-list path] text file with list of images; one image per line."
echo " [-i|--images path] tar.gz generated by docker save."
echo " [-h|--help] Usage message"
}
POSITIONAL=()
## $#是获取参数个数的意思
## -gt是大于的意思
## 所以这里是判断只有传入有参数时是才做while循环。
## 在 shell 中我们会见到 $0、$1、$2这样的符号,这是什么意思呢? 简单来说
## $0 就是你写的shell脚本本身的名字,
## $1 是你给你写的shell脚本传的第一个参数,
## $2 是你给你写的shell脚本传的第二个参数
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-i|--images)
images="$2"
shift # past argument
shift # past value
;;
-l|--image-list)
list="$2"
shift # past argument
shift # past value
;;
-h|--help)
help="true"
shift
;;
*)
usage
exit 1
;;
esac
done
if [[ $help ]]; then
usage
exit 0
fi
## IFS= read -r line 命令含义
## 设置read命令读取buffer过程中的域分隔符设置为空字符(IFS=),并在不转义转义字符的前提下读取一行文本buffer(read -r)给变量line
## -z 判断 变量的值是否为空,
## - 变量的值为空,返回0,为true;
## - 变量的值非空,返回1,为false;
## /dev/null :代表空设备文件
## > :代表重定向到哪里
## 1 :表示stdout标准输出,系统默认值是1,所以">/dev/null"等同于"1>/dev/null"
## 2 :表示stderr标准错误
## & :表示等同于的意思,2>&1,表示2的输出重定向等同于1
## 1 > /dev/null 2>&1 语句含义:
## 1 > /dev/null : 首先表示标准输出重定向到空设备文件,也就是不输出任何信息到终端,说白了就是不显示任何信息。
## 2>&1 :接着,标准错误输出重定向(等同于)标准输出,因为之前标准输出已经重定向到了空设备文件,所以标准错误输出也重定向到空设备文件。
pulled=""
while IFS= read -r i; do
[ -z "${i}" ] && continue
if docker pull "${i}" > /dev/null 2>&1; then
echo "Image pull success: ${i}"
pulled="${pulled} ${i}"
else
if docker inspect "${i}" > /dev/null 2>&1; then
pulled="${pulled} ${i}"
else
echo "Image pull failed: ${i}"
fi
fi
done < "${list}"
echo "Creating ${images} with $(echo ${pulled} | wc -w | tr -d '[:space:]') images"
docker save $(echo ${pulled}) | gzip --stdout > ${images}
</code></pre>
<h1>3.zysoft-images.txt内容:</h1>
<p>docker 默认从docker hub上拉取镜像,指定镜像仓库如下:</p>
<pre><code class="language-bash">registry.hzsun.com/library/nacos-server:v1.4.1
. . . . . .
registry.hzsun.com/easytong/easytong_server:5.1.21.0831
. . . . . .
registry.hzsun.com/micp/。。。
. . . . . .
registry.hzsun.com/ec-mss/。。。
. . . . . .
registry.hzsun.com/emp/。。。
. . . . . .
registry.hzsun.com/uias/。。。
. . . . . .
registry.hzsun.com/ocp/。。。
. . . . . . </code></pre>
<h1>2.rancher-images.sh内容:</h1>
<pre><code class="language-bash">busybox
rancher/backup-restore-operator:v1.0.2
rancher/banzaicloud-fluentd:v1.11.2-alpine-2
rancher/banzaicloud-logging-operator:3.6.0
rancher/calico-cni:v3.13.4
rancher/calico-cni:v3.16.1
rancher/calico-ctl:v3.13.4
rancher/calico-ctl:v3.16.1
rancher/calico-kube-controllers:v3.13.4
rancher/calico-kube-controllers:v3.16.1
rancher/calico-node:v3.13.4
rancher/calico-node:v3.16.1
rancher/calico-pod2daemon-flexvol:v3.13.4
rancher/calico-pod2daemon-flexvol:v3.16.1
rancher/cis-operator:v1.0.1
rancher/cluster-proportional-autoscaler:1.7.1
rancher/cluster-proportional-autoscaler:1.8.1
rancher/configmap-reload:v0.3.0-rancher2
rancher/coredns-coredns:1.6.2
rancher/coredns-coredns:1.6.5
rancher/coredns-coredns:1.6.9
rancher/coredns-coredns:1.7.0
rancher/coreos-etcd:v3.3.15-rancher1
rancher/coreos-etcd:v3.4.13-rancher1
rancher/coreos-etcd:v3.4.3-rancher1
rancher/coreos-flannel:v0.12.0
rancher/coreos-flannel:v0.13.0-rancher1
rancher/coreos-kube-state-metrics:v1.9.7
rancher/coreos-prometheus-config-reloader:v0.38.1
rancher/coreos-prometheus-operator:v0.38.1
rancher/curlimages-curl:7.70.0
rancher/directxman12-k8s-prometheus-adapter-amd64:v0.6.0
rancher/eks-operator:v1.0.4
rancher/flannel-cni:v0.3.0-rancher6
rancher/fleet-agent:v0.3.1
rancher/fleet:v0.3.1
rancher/fluent-bit-out-syslog:0.1.0
rancher/fluent-fluent-bit:1.5.4
rancher/fluent-fluent-bit:1.5.4-debug
rancher/fluentd:v0.1.19
rancher/gitjob:v0.1.8
rancher/grafana-grafana:6.7.4
rancher/grafana-grafana:7.1.5
rancher/hyperkube:v1.16.15-rancher1
rancher/hyperkube:v1.17.13-rancher1
rancher/hyperkube:v1.18.10-rancher1
rancher/hyperkube:v1.19.3-rancher1
rancher/istio-1.5-migration:0.1.1
rancher/istio-citadel:1.5.9
rancher/istio-coredns-plugin:0.2-istio-1.1
rancher/istio-galley:1.5.9
rancher/istio-install-cni:1.7.3
rancher/istio-installer:1.7.3-rancher2
rancher/istio-kubectl:1.4.6
rancher/istio-kubectl:1.5.10
rancher/istio-kubectl:1.5.9
rancher/istio-mixer:1.5.9
rancher/istio-mixer:1.7.3
rancher/istio-node-agent-k8s:1.5.9
rancher/istio-pilot:1.5.9
rancher/istio-pilot:1.7.3
rancher/istio-proxyv2:1.5.9
rancher/istio-proxyv2:1.7.3
rancher/istio-sidecar_injector:1.5.9
rancher/jaegertracing-all-in-one:1.14
rancher/jenkins-jnlp-slave:3.35-4
rancher/jetstack-cert-manager-controller:v0.8.1
rancher/jettech-kube-webhook-certgen:v1.2.1
rancher/jimmidyson-configmap-reload:v0.2.2
rancher/jimmidyson-configmap-reload:v0.3.0
rancher/k3s-upgrade:v1.17.13-k3s2
rancher/k3s-upgrade:v1.18.10-k3s2
rancher/k3s-upgrade:v1.19.3-k3s2
rancher/k8s-dns-dnsmasq-nanny:1.15.0
rancher/k8s-dns-dnsmasq-nanny:1.15.10
rancher/k8s-dns-dnsmasq-nanny:1.15.2
rancher/k8s-dns-kube-dns:1.15.0
rancher/k8s-dns-kube-dns:1.15.10
rancher/k8s-dns-kube-dns:1.15.2
rancher/k8s-dns-node-cache:1.15.13
rancher/k8s-dns-node-cache:1.15.7
rancher/k8s-dns-sidecar:1.15.0
rancher/k8s-dns-sidecar:1.15.10
rancher/k8s-dns-sidecar:1.15.2
rancher/kiali-kiali:v1.17
rancher/kiali-kiali:v1.24.0
rancher/kiwigrid-k8s-sidecar:0.1.151
rancher/klipper-helm:v0.2.3
rancher/klipper-helm:v0.2.7
rancher/klipper-helm:v0.3.0
rancher/klipper-lb:v0.1.2
rancher/kube-api-auth:v0.1.4
rancher/kubectl:v1.18.0
rancher/kubectl:v1.18.6
rancher/kubernetes-external-dns:v0.7.3
rancher/library-busybox:1.31.1
rancher/library-nginx:1.19.2-alpine
rancher/library-traefik:1.7.19
rancher/local-path-provisioner:v0.0.11
rancher/local-path-provisioner:v0.0.14
rancher/log-aggregator:v0.1.7
rancher/longhornio-csi-attacher:v2.0.0
rancher/longhornio-csi-node-driver-registrar:v1.2.0
rancher/longhornio-csi-provisioner:v1.4.0
rancher/longhornio-csi-resizer:v0.3.0
rancher/longhornio-longhorn-engine:v1.0.2
rancher/longhornio-longhorn-instance-manager:v1_20200514
rancher/longhornio-longhorn-manager:v1.0.2
rancher/longhornio-longhorn-ui:v1.0.2
rancher/metrics-server:v0.3.4
rancher/metrics-server:v0.3.6
rancher/minio-minio:RELEASE.2020-07-13T18-09-56Z
rancher/nginx-ingress-controller-defaultbackend:1.5-rancher1
rancher/nginx-ingress-controller:nginx-0.35.0-rancher2
rancher/opa-gatekeeper:v3.1.0-beta.7
rancher/openpolicyagent-gatekeeper:v3.1.1
rancher/openzipkin-zipkin:2.14.2
rancher/pause:3.1
rancher/pause:3.2
rancher/pipeline-jenkins-server:v0.1.4
rancher/pipeline-tools:v0.1.15
rancher/plugins-docker:18.09
rancher/prom-alertmanager:v0.21.0
rancher/prom-node-exporter:v1.0.1
rancher/prom-prometheus:v2.12.0
rancher/prom-prometheus:v2.18.2
rancher/prometheus-auth:v0.2.1
rancher/pstauffer-curl:v1.0.3
rancher/pushprox-client:v0.1.0-rancher1-client
rancher/pushprox-proxy:v0.1.0-rancher1-proxy
rancher/rancher-agent:v2.4.8
rancher/rancher-agent:v2.5.2
rancher/rancher-operator:v0.1.1
rancher/rancher-webhook:v0.1.0-beta7
rancher/rancher:v2.5.2
rancher/rke-tools:v0.1.66
rancher/security-scan:v0.1.14
rancher/security-scan:v0.2.1
rancher/shell:v0.1.5
rancher/sonobuoy-sonobuoy:v0.16.3
rancher/squareup-ghostunnel:v1.5.2
rancher/system-upgrade-controller:v0.6.2
rancher/tekton-utils:v0.1.0
rancher/thanosio-thanos:v0.15.0
rancher/webhook-receiver:v0.2.4
registry:2</code></pre>