Last active
July 26, 2017 12:41
-
-
Save arcolife/082e7d2327fc8b1f1aa10786ebb158af to your computer and use it in GitHub Desktop.
generate 20K images in OCP
This file contains hidden or 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 | |
| # Usage: $ ./generate_builds.sh [count start] [count end] | |
| # Example: (to generate 40K images): | |
| # $ for i in $(seq 1 500 40000); do ./generate_builds.sh $i `expr $i + 500`; done | |
| seq_init=$1 | |
| count=$2 | |
| registry='70.30.60.158:5000' | |
| docker login -u admin -p $(oc whoami -t) $registry | |
| labels=$(./label_gen.py) | |
| patch_template='{ "metadata": { "labels": '$labels' }}' | |
| if [ -f /tmp/ocp_image_sha_ids.log ]; then | |
| rm -f /tmp/ocp_image_sha_ids.log | |
| fi | |
| for i in $(seq $seq_init $count); do | |
| sed s/\".\"/\"$i\"/g -i hello.py | |
| echo "building image $i" | |
| docker build . -t hello$i 2>&1 > /dev/null | |
| echo "tagging image $i" | |
| docker tag hello$i $registry/admin/hello$i | |
| echo "executing: docker push $registry/admin/hello$i" | |
| docker push $registry/admin/hello$i 2>&1 | grep latest | sed -n -e 's/^.*\(sha.*\) size.*/\1/p' >> /tmp/ocp_image_sha_ids.log & | |
| done | |
| wait | |
| while read image_object; do | |
| echo "patching $image_object" | |
| oc patch image/$image_object -p "$patch_template" & | |
| done < /tmp/ocp_image_sha_ids.log | |
| wait | |
| token=$(oc sa get-token -n management-infra management-admin) | |
| is_c=`curl -s -L -H "Authorization: Bearer $token" -k -XGET https://10.16.31.50:8443/oapi/v1/imagestreams | grep selfLink -c` | |
| echo "Total ImageStreams: $is_c" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment