From 6c70333e0ab1b5ff3cb8cb23cfc30ce250b10ba9 Mon Sep 17 00:00:00 2001 From: Anna Kapuscinska Date: Thu, 27 Jul 2023 18:37:03 +0100 Subject: [PATCH] contrib: Support upgrade in install-tetragon.sh Using `helm upgrade --install` instead of `helm install` makes it possible to use the same script for both installing and upgrading Tetragon in a Kubernetes cluster. Also added a timeout for `kubectl rollout status` command to prevent the script from hanging forever, and made some minor changes to improve maintainability. Signed-off-by: Anna Kapuscinska --- contrib/localdev/bootstrap-kind-cluster.sh | 4 ++-- contrib/localdev/install-tetragon.sh | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/contrib/localdev/bootstrap-kind-cluster.sh b/contrib/localdev/bootstrap-kind-cluster.sh index 59625e20190..1ec8f7a7b5a 100755 --- a/contrib/localdev/bootstrap-kind-cluster.sh +++ b/contrib/localdev/bootstrap-kind-cluster.sh @@ -1,13 +1,13 @@ #! /bin/bash error() { - echo $@ 1>&2 + echo "$@" 1>&2 exit 1 } set -eu -PROJECT_ROOT="$(realpath $(dirname "${BASH_SOURCE[0]}")/../..)" +PROJECT_ROOT="$(git rev-parse --show-toplevel)" cd "$PROJECT_ROOT" source contrib/localdev/conf diff --git a/contrib/localdev/install-tetragon.sh b/contrib/localdev/install-tetragon.sh index 6febab5b59d..8a784c092bb 100755 --- a/contrib/localdev/install-tetragon.sh +++ b/contrib/localdev/install-tetragon.sh @@ -1,13 +1,13 @@ #! /bin/bash error() { - echo $@ 1>&2 + echo "$@" 1>&2 exit 1 } set -eu -PROJECT_ROOT="$(realpath $(dirname "${BASH_SOURCE[0]}")/../..)" +PROJECT_ROOT="$(git rev-parse --show-toplevel)" cd "$PROJECT_ROOT" source contrib/localdev/conf @@ -72,26 +72,26 @@ if [ "$FORCE" == 1 ]; then fi # Set helm options -declare -a helm_opts=("install" "--namespace" "kube-system") -if [ ! -z "$IMAGE" ]; then +declare -a helm_opts=("--namespace" "kube-system") +if [ -n "$IMAGE" ]; then helm_opts+=("--set" "tetragon.image.override=$IMAGE") if [ "$IS_KIND" == 1 ]; then kind load docker-image "$IMAGE" --name "$CLUSTER_NAME" fi fi -if [ ! -z "$OPERATOR" ]; then +if [ -n "$OPERATOR" ]; then helm_opts+=("--set" "tetragonOperator.image.override=$OPERATOR") if [ "$IS_KIND" == 1 ]; then kind load docker-image "$OPERATOR" --name "$CLUSTER_NAME" fi fi -if [ ! -z "$VALUES" ]; then +if [ -n "$VALUES" ]; then helm_opts+=("--values" "$VALUES") fi helm_opts+=("tetragon" "./install/kubernetes") echo "Installing Tetragon in cluster..." 1>&2 -helm "${helm_opts[@]}" +helm upgrade --install "${helm_opts[@]}" echo "Waiting for Tetragon deployment..." 1>&2 -kubectl rollout status -n kube-system ds/tetragon -w +kubectl rollout status -n kube-system ds/tetragon -w --timeout 5m