Created
February 22, 2017 15:38
-
-
Save mjudeikis/e97e4c623e703e4d9379cc801fc077fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
yum install -y skopeo | |
if [ ! -f /usr/local/bin/oc ]; then | |
wget https://github.com/openshift/origin/releases/download/v1.4.1/openshift-origin-client-tools-v1.4.1-3f9807a-linux-64bit.tar.gz -O /tmp/oc.tar.gz | |
cd /tmp; tar -zxvf /tmp/oc.tar.gz; cp openshift-origin-client-tools-*/oc /usr/local/bin/ | |
fi | |
oc login -u admin -p admin docker-registry-default.apps.192.168.2.168.xip.io:8443 --insecure-skip-tls-verify=true | |
TOKEN=$(oc whoami -t) | |
OCP_VERSION="3.4.0" | |
OCP_VERSION_LONG="v3.4.1.5" | |
OCP_VERSION_SHORT="3.4" | |
REGISTRY="registry.access.redhat.com" | |
CENTRAL_REGISTRY="docker-registry-default.apps.192.168.2.168.xip.io" | |
PROJECT_LIST=( | |
openshift3 | |
jboss-webserver-3 | |
rhscl | |
dotnet | |
) | |
CORE_IMAGES=( | |
jboss-webserver-3/webserver30-tomcat7-openshift | |
jboss-webserver-3/webserver30-tomcat8-openshift | |
openshift3/image-inspector | |
openshift3/jenkins-1-rhel7 | |
openshift3/jenkins-2-rhel7 | |
#logging/metricsimages | |
openshift3/logging-auth-proxy | |
openshift3/logging-deployment | |
openshift3/logging-elasticsearch | |
openshift3/logging-fluentd | |
openshift3/logging-kibana | |
openshift3/logging-curator | |
openshift3/metrics-cassandra | |
openshift3/metrics-deployer | |
openshift3/metrics-hawkular-metrics | |
openshift3/metrics-heapster | |
#coreimages | |
openshift3/ose-deployer | |
openshift3/ose-docker-builder | |
openshift3/ose-docker-registry | |
openshift3/ose-haproxy-router | |
openshift3/ose-pod | |
openshift3/ose-recycler | |
openshift3/ose-sti-builder | |
) | |
# it was generated by this command from standart ocp cluster | |
# oc get is -n openshift -o yaml | grep "name: registry.access" | awk -F '/' '{print $2"/"$3}' | |
#those are little bit different and version is in NAME itself | |
APP_IMAGES=( | |
dotnet/dotnetcore-10-rhel7:1.0 | |
dotnet/dotnetcore-11-rhel7:1.1 | |
openshift3/jenkins-1-rhel7:latest | |
openshift3/jenkins-2-rhel7:latest | |
rhscl/mariadb-101-rhel7:latest | |
openshift3/mongodb-24-rhel7:latest | |
rhscl/mongodb-26-rhel7:latest | |
rhscl/mongodb-32-rhel7:latest | |
openshift3/mysql-55-rhel7:latest | |
rhscl/mysql-56-rhel7:latest | |
rhscl/mysql-57-rhel7:latest | |
openshift3/nodejs-010-rhel7:latest | |
rhscl/nodejs-4-rhel7:latest | |
openshift3/perl-516-rhel7:latest | |
rhscl/perl-520-rhel7:latest | |
rhscl/perl-524-rhel7:latest | |
openshift3/php-55-rhel7:latest | |
rhscl/php-56-rhel7:latest | |
rhscl/php-70-rhel7:latest | |
openshift3/postgresql-92-rhel7:latest | |
rhscl/postgresql-94-rhel7:latest | |
rhscl/postgresql-95-rhel7:latest | |
rhscl/python-27-rhel7:latest | |
openshift3/python-33-rhel7:latest | |
rhscl/python-34-rhel7:latest | |
rhscl/python-35-rhel7:latest | |
rhscl/redis-32-rhel7:latest | |
openshift3/ruby-20-rhel7:latest | |
rhscl/ruby-22-rhel7:latest | |
rhscl/ruby-23-rhel7:latest | |
) | |
#create all namespaces | |
## for each namespace | |
for namespespace in "${PROJECT_LIST[@]}"; do | |
oc new-project $namespespace | |
done | |
###############################################import core images | |
for coreimage in "${CORE_IMAGES[@]}"; do | |
## grab a list of available tags | |
tags=$(curl -s https://registry.access.redhat.com/v1/repositories/${coreimage}/tags | python -c " | |
import json | |
import random | |
import string | |
import sys | |
def key_val(pairs, key): | |
for k in pairs: | |
if k["Key"] == key: | |
return k["Value"] | |
return None | |
j = json.loads(sys.stdin.read()) | |
for r in j: | |
print r | |
") | |
# for each tag | |
for tag in $tags; do | |
## tags with hyphens are skipped as this represent intermediate builds | |
if [[ "$tag" = *"{$OCP_VERSION}"* || "$tag" = *"${OCP_VERSION_LONG}"* || "$tag" = *"${OCP_VERSION_SHORT}"* ]]; then | |
echo "prefetching $coreimage:$tag" | |
skopeo copy docker://$REGISTRY/$coreimage:$tag atomic:$CENTRAL_REGISTRY/$coreimage:$tag --dest-creds=admin:$TOKEN --dest-tls-verify=false | |
else | |
echo "skipping $coreimage:$tag" | |
# skopeo copy docker://$REGISTRY/$coreimage:$tag atomic:$CENTRAL_REGISTRY/$coreimage:$tag --dest-creds=admin:$TOKEN | |
fi | |
done | |
done | |
###############################################import APP images | |
for appimage in "${APP_IMAGES[@]}"; do | |
## grab a list of available tags | |
echo "prefetching $appimage" | |
skopeo copy docker://$REGISTRY/$appimage atomic:$CENTRAL_REGISTRY/$appimage --dest-creds=admin:$TOKEN --dest-tls-verify=false | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment