From 63ce112d9e1cee3afcc16c07e90d7ea188652f62 Mon Sep 17 00:00:00 2001 From: Shyam Jeedigunta Date: Fri, 31 Aug 2018 18:56:36 +0200 Subject: [PATCH] GC kubemark image after cluster starts up --- cluster/gce/util.sh | 5 +++++ cluster/kubemark/gce/config-default.sh | 1 + test/kubemark/start-kubemark.sh | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index adc33491d2..b43f30f91b 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -3130,3 +3130,8 @@ function ssh-to-node() { function prepare-e2e() { detect-project } + +# Delete the image given by $1. +function delete-image() { + gcloud container images delete --quiet "$1" +} diff --git a/cluster/kubemark/gce/config-default.sh b/cluster/kubemark/gce/config-default.sh index 2414499927..e80feb79bd 100644 --- a/cluster/kubemark/gce/config-default.sh +++ b/cluster/kubemark/gce/config-default.sh @@ -39,6 +39,7 @@ MASTER_OS_DISTRIBUTION=${KUBE_MASTER_OS_DISTRIBUTION:-gci} NODE_OS_DISTRIBUTION=${KUBE_NODE_OS_DISTRIBUTION:-gci} MASTER_IMAGE=${KUBE_GCE_MASTER_IMAGE:-cos-stable-65-10323-64-0} MASTER_IMAGE_PROJECT=${KUBE_GCE_MASTER_PROJECT:-cos-cloud} +CLEANUP_KUBEMARK_IMAGE=${CLEANUP_KUBEMARK_IMAGE:-true} # GPUs supported in GCE do not have compatible drivers in Debian 7. if [[ "${NODE_OS_DISTRIBUTION}" == "debian" ]]; then diff --git a/test/kubemark/start-kubemark.sh b/test/kubemark/start-kubemark.sh index f4eaf59ca1..a0233f5eff 100755 --- a/test/kubemark/start-kubemark.sh +++ b/test/kubemark/start-kubemark.sh @@ -220,6 +220,14 @@ function create-and-upload-hollow-node-image { cd $CURR_DIR fi echo "Created and uploaded the kubemark hollow-node image to docker registry." + # Cleanup the kubemark image after the script exits. + if [[ "${CLEANUP_KUBEMARK_IMAGE:-}" == "true" ]]; then + trap delete-kubemark-image EXIT + fi +} + +function delete-kubemark-image { + delete-image "${KUBEMARK_IMAGE_REGISTRY}/kubemark:${KUBEMARK_IMAGE_TAG}" } # Generate secret and configMap for the hollow-node pods to work, prepare