1
+ #! /bin/bash
2
+ # Modified script from (@fabiorapposelli) to mirror TKG 1.0 (GA) containers into local Harbor Registry
3
+
4
+ REGISTRY_URL=registry.virtuallyghetto.com
5
+ TKG_CLI_PATH=/usr/local/bin/tkg
6
+
7
+ if [ ! -e ${TKG_CLI_PATH} ]; then
8
+ echo " Unable to find tkg binary in ${TKG_CLI_PATH} ... exiting"
9
+ exit 1
10
+ fi
11
+
12
+ LIST=(
13
+ registry.tkg.vmware.run/kind/node:v1.17.3_vmware.2
14
+ registry.tkg.vmware.run/cluster-api/cluster-api-aws-controller:v0.5.2_vmware.1
15
+ registry.tkg.vmware.run/cluster-api/kubeadm-control-plane-controller:v0.3.3_vmware.1
16
+ registry.tkg.vmware.run/cluster-api/kubeadm-bootstrap-controller:v0.3.3_vmware.1
17
+ registry.tkg.vmware.run/cluster-api/cluster-api-controller:v0.3.3_vmware.1
18
+ registry.tkg.vmware.run/cluster-api/cluster-api-vsphere-controller:v0.6.3_vmware.1
19
+ registry.tkg.vmware.run/csi/volume-metadata-syncer:v1.0.2_vmware.1
20
+ registry.tkg.vmware.run/ccm/manager:v1.1.0_vmware.2
21
+ registry.tkg.vmware.run/csi/vsphere-block-csi-driver:v1.0.2_vmware.1
22
+ registry.tkg.vmware.run/csi/csi-provisioner:v1.4.0_vmware.2
23
+ registry.tkg.vmware.run/csi/csi-attacher:v1.1.1_vmware.7
24
+ registry.tkg.vmware.run/csi/csi-node-driver-registrar:v1.1.0_vmware.7
25
+ registry.tkg.vmware.run/csi/csi-livenessprobe:v1.1.0_vmware.7
26
+ registry.tkg.vmware.run/calico-all/node:v3.11.2_vmware.1
27
+ registry.tkg.vmware.run/calico-all/pod2daemon:v3.11.2_vmware.1
28
+ registry.tkg.vmware.run/calico-all/cni-plugin:v3.11.2_vmware.1
29
+ registry.tkg.vmware.run/calico-all/kube-controllers:v3.11.2_vmware.1
30
+ registry.tkg.vmware.run/cluster-api/kube-rbac-proxy:v0.4.1_vmware.2
31
+ registry.tkg.vmware.run/cert-manager/cert-manager-controller:v0.11.0_vmware.1
32
+ registry.tkg.vmware.run/cert-manager/cert-manager-cainjector:v0.11.0_vmware.1
33
+ registry.tkg.vmware.run/cert-manager/cert-manager-webhook:v0.11.0_vmware.1
34
+ )
35
+
36
+ newImageRepo=" ${REGISTRY_URL} \/library"
37
+ sourceDir=" /root/.tkg"
38
+
39
+ ${TKG_CLI_PATH} get mc
40
+
41
+ echo ' > Start mirroring process'
42
+ for image in " ${LIST[@]} "
43
+ do
44
+ :
45
+ image=${image// [$'\t\r\n ']}
46
+ origImageRepo=$( echo " $image " | awk -F/ ' { print $1 }' )
47
+ imageDestination=$( echo -n " $image " | sed " s/$origImageRepo /$newImageRepo /g" )
48
+ echo " > Pulling $image "
49
+ docker pull " $image "
50
+ # Do not push KIND container into Harbor as this is only used locally
51
+ if [ " $image " != " registry.tkg.vmware.run/kind/node:v1.17.3_vmware.2" ]; then
52
+ echo " > Tagging $image -> $imageDestination "
53
+ docker tag " $image " " $imageDestination "
54
+ echo " > Pushing $imageDestination "
55
+ docker push " $imageDestination "
56
+ docker rmi " $image "
57
+ fi
58
+ # Leaving these containers cached in Photon to speed up KIND deployment
59
+ if [[ " $imageDestination " != " ${REGISTRY_URL} /library/cert-manager/cert-manager-webhook:v0.11.0_vmware.1" ]] && [[ " $imageDestination " != " ${REGISTRY_URL} /library/cert-manager/cert-manager-cainjector:v0.11.0_vmware.1" ]] && [[ " $imageDestination " != " ${REGISTRY_URL} /library/cert-manager/cert-manager-controller:v0.11.0_vmware.1" ]]; then
60
+ docker rmi " $imageDestination "
61
+ fi
62
+ done
63
+
64
+ echo " > Pointing all image repos to $newImageRepo "
65
+ grep -RiIl ' mage: ' " $sourceDir " | xargs perl -i -pe " s/mage: .*?\/(.*)/mage: ${newImageRepo// ./ \\ .} \/\1/"
0 commit comments