From 76c004e89d4976a76f4020faf919511889e7b7fa Mon Sep 17 00:00:00 2001 From: Konstantina Skovola <konstantina.skovola@cern.ch> Date: Fri, 10 May 2024 14:23:21 +0200 Subject: [PATCH] Add redeploy script --- continuousintegration/ci_runner/redeploy.sh | 63 +++++++++++++++++++ .../orchestration/delete_instance.sh | 2 +- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100755 continuousintegration/ci_runner/redeploy.sh diff --git a/continuousintegration/ci_runner/redeploy.sh b/continuousintegration/ci_runner/redeploy.sh new file mode 100755 index 0000000000..10bfdee745 --- /dev/null +++ b/continuousintegration/ci_runner/redeploy.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# @project The CERN Tape Archive (CTA) +# @copyright Copyright © 2024 CERN +# @license This program is free software, distributed under the terms of the GNU General Public +# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". You can +# redistribute it and/or modify it under the terms of the GPL Version 3, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# In applying this licence, CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization or +# submit itself to any jurisdiction. + +IMAGE_TAG=${1:-dev} #default tag is dev +KUBE_NAMESPACE=${2:-stress} + +if [ "$#" -ge 3 ]; then + echo "Usage: The script $0 takes two optional arguments: image tag (1) and namespace name (2)" + exit 1 +fi + +echo "Launching redeploy script; image tag is $IMAGE_TAG, namespace name is $KUBE_NAMESPACE" + +# Script should be run as cirunner +if [[ $(whoami) != 'cirunner' ]] +then + echo "Current user is $(whoami), aborting. Script must run as cirunner" + exit 1 +fi + +# Delete previous instance, if it exists +echo "Deleting the old namespace, if it exists" +cd ~/CTA/continuousintegration/orchestration/ && ./delete_instance.sh -n $KUBE_NAMESPACE + +# Clear the old image and namespace +echo "Deleting old image and removing it from minikube" +podman rmi ctageneric:$IMAGE_TAG +minikube image rm localhost/ctageneric:$IMAGE_TAG +cd ~/CTA/continuousintegration/ci_runner +rm -rf ctageneric.tar + +## Create and load the new images +# Prepare new image +echo "Preparing new image" +cd ~/CTA/continuousintegration/ci_runner # should already be here +./prepareImage.sh ~/CTA_rpm/RPM/RPMS/x86_64 $IMAGE_TAG +# Save the image in a tar file +echo "Saving new image" +podman save -o ctageneric.tar localhost/ctageneric:$IMAGE_TAG +# Load the new image +echo "Loading new image into minikube" +minikube image load ctageneric.tar localhost/ctageneric:$IMAGE_TAG + +# Redeploy containers +echo "Redeploying container" +cd ~/CTA/continuousintegration/orchestration +./create_instance.sh -n $KUBE_NAMESPACE -i $IMAGE_TAG -D -O -d internal_postgres.yaml + + diff --git a/continuousintegration/orchestration/delete_instance.sh b/continuousintegration/orchestration/delete_instance.sh index cd27e60925..3a2d58856c 100755 --- a/continuousintegration/orchestration/delete_instance.sh +++ b/continuousintegration/orchestration/delete_instance.sh @@ -114,7 +114,7 @@ echo OK # this now useless as dummy NFS PV were replaced by local volumes # those are recycled automatically -./recycle_librarydevice_PV.sh +# ./recycle_librarydevice_PV.sh echo "Status of library pool after test:" kubectl get pv -- GitLab