Created
April 5, 2023 13:07
-
-
Save mtardy/000df05890c6ff145c2e64afd88b8364 to your computer and use it in GitHub Desktop.
Little wizard to install Tetragon using helm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
usage() { | |
echo "Usage: | |
$0 {flags} | |
Flags: | |
-c Helm chart to use (default \"cilium/tetragon\") | |
-n Namespace for Tetragon installation (default \"kube-system\") | |
-t Tag for tetragon.image.tag and tetragonOperator.image.tag (default \"latest\") | |
-r Use release repository: quay.io/cilium/tetragon (default \"quay.io/cilium/tetragon-ci\") | |
-h Display this message" | |
} | |
REPOSITORY_TETRAGON=quay.io/cilium/tetragon | |
REPOSITORY_OPERATOR=quay.io/cilium/tetragon-operator | |
TAG=$(curl --silent "https://api.github.com/repos/cilium/tetragon/releases/latest" | awk -F'"' '/tag_name/ {print $4}') | |
HELM_CHART=cilium/tetragon | |
EXPORT_STDOUT_TAG=v1.0.3 | |
while getopts ":n:t:c:rh" opt; do | |
case ${opt} in | |
n) | |
NAMESPACE="${OPTARG}" | |
;; | |
t) | |
TAG="${OPTARG}" | |
;; | |
c) | |
HELM_CHART="${OPTARG}" | |
;; | |
r) | |
REPOSITORY_TETRAGON=quay.io/cilium/tetragon | |
REPOSITORY_OPERATOR=quay.io/cilium/tetragon-operator | |
;; | |
h) | |
usage | |
exit 0 | |
;; | |
\?) | |
echo "error: invalid option: -$OPTARG" 1>&2 | |
usage 1>&2 | |
exit 1 | |
;; | |
:) | |
echo "error: option -$OPTARG requires an argument." 1>&2 | |
usage 1>&2 | |
exit 1 | |
;; | |
esac | |
done | |
helm install -n kube-system tetragon $HELM_CHART \ | |
--set tetragon.image.tag=$TAG \ | |
--set tetragon.image.repository=$REPOSITORY_TETRAGON \ | |
--set tetragonOperator.image.tag=$TAG \ | |
--set tetragonOperator.image.repository=$REPOSITORY_OPERATOR \ | |
--set export.stdout.image.tag=$EXPORT_STDOUT_TAG | |
if [ $? -ne 0 ]; then | |
echo -e "\nFailed to \"helm install\", trying \"helm upgrade\"\n" | |
helm upgrade -n kube-system tetragon $HELM_CHART \ | |
--set tetragon.image.tag=$TAG \ | |
--set tetragon.image.repository=$REPOSITORY_TETRAGON \ | |
--set tetragonOperator.image.tag=$TAG \ | |
--set tetragonOperator.image.repository=$REPOSITORY_OPERATOR \ | |
--set export.stdout.image.tag=$EXPORT_STDOUT_TAG | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment