Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit 7989d07

Browse files
authored
Merge pull request #235 from aaronlevy/gceprefix
tests: parameterize prefix for GCE assets in conformance tests
2 parents 49a9dc5 + 8cd8bd8 commit 7989d07

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

hack/tests/conformance-gce.sh

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ BOOTKUBE_REPO=${BOOTKUBE_REPO:-}
3131
BOOTKUBE_VERSION=${BOOTKUBE_VERSION:-}
3232
COREOS_IMAGE=${COREOS_IMAGE:-'https://www.googleapis.com/compute/v1/projects/coreos-cloud/global/images/coreos-stable-1122-2-0-v20160906'}
3333
WORKER_COUNT=4
34+
GCE_PREFIX=${GCE_PREFIX:-'bootkube-ci'}
3435

3536
function cleanup {
36-
gcloud compute instances delete --quiet --zone us-central1-a bootkube-ci-m1 || true
37-
gcloud compute firewall-rules delete --quiet bootkube-ci-api-443 || true
37+
gcloud compute instances delete --quiet --zone us-central1-a ${GCE_PREFIX}-m1 || true
38+
gcloud compute firewall-rules delete --quiet ${GCE_PREFIX}-api-443 || true
3839
for i in $(seq 1 ${WORKER_COUNT}); do
39-
gcloud compute instances delete --quiet --zone us-central1-a bootkube-ci-w${i} || true
40+
gcloud compute instances delete --quiet --zone us-central1-a ${GCE_PREFIX}-w${i} || true
4041
done
4142
rm -rf /build/cluster
4243
}
@@ -45,36 +46,36 @@ function init {
4546
curl https://sdk.cloud.google.com | bash
4647
source ~/.bashrc
4748
gcloud config set project coreos-gce-testing
48-
gcloud auth activate-service-account bootkube-ci@coreos-gce-testing.iam.gserviceaccount.com --key-file=/build/keyfile
49+
gcloud auth activate-service-account ${GCE_PREFIX}@coreos-gce-testing.iam.gserviceaccount.com --key-file=/build/keyfile
4950
apt-get update && apt-get install -y jq
5051

5152
ssh-keygen -t rsa -f /root/.ssh/id_rsa -N ""
52-
awk '{print "core:" $1 " " $2 " core@bootkube-ci"}' /root/.ssh/id_rsa.pub > /root/.ssh/gce-format.pub
53+
awk '{print "core:" $1 " " $2 " core@conformance"}' /root/.ssh/id_rsa.pub > /root/.ssh/gce-format.pub
5354
}
5455

5556
function add_master {
56-
gcloud compute instances create bootkube-ci-m1 \
57+
gcloud compute instances create ${GCE_PREFIX}-m1 \
5758
--image ${COREOS_IMAGE} --zone us-central1-a --machine-type n1-standard-4 --boot-disk-size=10GB
5859

59-
gcloud compute instances add-tags --zone us-central1-a bootkube-ci-m1 --tags bootkube-ci-apiserver
60-
gcloud compute firewall-rules create bootkube-ci-api-443 --target-tags=bootkube-ci-apiserver --allow tcp:443
60+
gcloud compute instances add-tags --zone us-central1-a ${GCE_PREFIX}-m1 --tags ${GCE_PREFIX}-apiserver
61+
gcloud compute firewall-rules create ${GCE_PREFIX}-api-443 --target-tags=${GCE_PREFIX}-apiserver --allow tcp:443
6162

62-
gcloud compute instances add-metadata bootkube-ci-m1 --zone us-central1-a --metadata-from-file ssh-keys=/root/.ssh/gce-format.pub
63+
gcloud compute instances add-metadata ${GCE_PREFIX}-m1 --zone us-central1-a --metadata-from-file ssh-keys=/root/.ssh/gce-format.pub
6364

64-
MASTER_IP=$(gcloud compute instances list bootkube-ci-m1 --format=json | jq --raw-output '.[].networkInterfaces[].accessConfigs[].natIP')
65+
MASTER_IP=$(gcloud compute instances list ${GCE_PREFIX}-m1 --format=json | jq --raw-output '.[].networkInterfaces[].accessConfigs[].natIP')
6566
cd /build/bootkube/hack/quickstart && SSH_OPTS="-o StrictHostKeyChecking=no" \
6667
CLUSTER_DIR=/build/cluster BOOTKUBE_REPO=${BOOTKUBE_REPO} BOOTKUBE_VERSION=${BOOTKUBE_VERSION} ./init-master.sh ${MASTER_IP}
6768
}
6869

6970
function add_workers {
7071
#TODO (aaron): parallelize launching workers
7172
for i in $(seq 1 ${WORKER_COUNT}); do
72-
gcloud compute instances create bootkube-ci-w${i} \
73+
gcloud compute instances create ${GCE_PREFIX}-w${i} \
7374
--image ${COREOS_IMAGE} --zone us-central1-a --machine-type n1-standard-1
7475

75-
gcloud compute instances add-metadata bootkube-ci-w${i} --zone us-central1-a --metadata-from-file ssh-keys=/root/.ssh/gce-format.pub
76+
gcloud compute instances add-metadata ${GCE_PREFIX}-w${i} --zone us-central1-a --metadata-from-file ssh-keys=/root/.ssh/gce-format.pub
7677

77-
local WORKER_IP=$(gcloud compute instances list bootkube-ci-w${i} --format=json | jq --raw-output '.[].networkInterfaces[].accessConfigs[].natIP')
78+
local WORKER_IP=$(gcloud compute instances list ${GCE_PREFIX}-w${i} --format=json | jq --raw-output '.[].networkInterfaces[].accessConfigs[].natIP')
7879
cd /build/bootkube/hack/quickstart && SSH_OPTS="-o StrictHostKeyChecking=no" ./init-worker.sh ${WORKER_IP} /build/cluster/auth/kubeconfig
7980
done
8081
}

0 commit comments

Comments
 (0)