github.com/rkt/rkt@v1.30.1-0.20200224141603-171c416fac02/tests/rkt-monitor/build-too-many-apps.sh (about) 1 #!/usr/bin/env bash 2 set -e 3 4 if ! [[ "$0" =~ "tests/rkt-monitor/build-too-many-apps.sh" ]]; then 5 echo "must be run from repository root" 6 exit 255 7 fi 8 9 NUM_APPS=100 10 11 # Build worker binary 12 13 echo "Building worker binary" 14 make rkt-monitor 15 16 # Generate worker images 17 18 acbuildEnd() { 19 export EXIT=$? 20 acbuild --debug end && exit $EXIT 21 } 22 trap acbuildEnd EXIT 23 24 mkdir -p ./too-many-apps-images 25 26 for i in $(seq 1 ${NUM_APPS}); 27 do 28 NAME="worker-${i}" 29 30 echo "Building image ${NAME}" 31 32 acbuild begin 33 acbuild copy build-rkt-1.8.0+git/bin/sleeper /worker-binary 34 acbuild set-exec /worker-binary 35 acbuild set-name ${NAME} 36 acbuild write --overwrite too-many-apps-images/${NAME}.aci 37 acbuild end 38 done 39 40 # Generate pod manifest 41 42 echo "Generating pod manifest" 43 44 OUTPUT=${PWD}/too-many-apps.podmanifest 45 46 cat <<EOF >${OUTPUT} 47 { 48 "acVersion": "0.8.11", 49 "acKind": "PodManifest", 50 "apps": [ 51 EOF 52 53 appSection() { 54 SHA512=$(gunzip too-many-apps-images/${1}.aci --stdout|sha512sum) 55 SHA512="sha512-${SHA512:0:32}" 56 57 cat <<EOF >>$2 58 { 59 "name": "$1", 60 "image": { 61 "name": "$1", 62 "id": "$SHA512", 63 "labels": [ 64 { 65 "name": "arch", 66 "value": "amd64" 67 }, 68 { 69 "name": "os", 70 "value": "linux" 71 } 72 ] 73 }, 74 "app": { 75 "exec": [ "/worker-binary" ], 76 "group": "0", 77 "user": "0" 78 } 79 } 80 EOF 81 } 82 83 appSection "worker-1" ${OUTPUT} 84 for i in $(seq 2 ${NUM_APPS}); 85 do 86 echo ',' >> ${OUTPUT} 87 appSection "worker-${i}" ${OUTPUT} 88 done 89 90 echo ']}' >> ${OUTPUT} 91