From 1297af70aa89dc8415a332d7e59ab8049e92fce2 Mon Sep 17 00:00:00 2001 From: Corneil du Plessis Date: Fri, 27 Sep 2024 15:52:32 +0200 Subject: [PATCH] [CI] Improve k8s setup scripts. (#5942) --- src/deploy/k8s/configure-k8s.sh | 2 ++ src/deploy/k8s/set-ver.sh | 11 ++++++++--- src/deploy/k8s/use-gke.sh | 10 +--------- src/deploy/k8s/use-microk8s.sh | 10 +--------- src/deploy/k8s/use-mk.sh | 4 ++-- src/deploy/k8s/use-tmc.sh | 10 +--------- 6 files changed, 15 insertions(+), 32 deletions(-) diff --git a/src/deploy/k8s/configure-k8s.sh b/src/deploy/k8s/configure-k8s.sh index 1642b4da6c..5737fdfb3f 100755 --- a/src/deploy/k8s/configure-k8s.sh +++ b/src/deploy/k8s/configure-k8s.sh @@ -52,10 +52,12 @@ case "$K8S_DRIVER" in ;; "microk8s") echo "Configure Microk8s" + microk8s start microk8s enable registry microk8s enable hostpath-storage microk8s enable metallb:172.18.0.1-172.18.0.254 microk8s kubectl get all --all-namespaces + microk8s config > $HOME/.kube/config ;; *) echo "Creating Minikube cluster with $K8S_DRIVER and k8s=$K8S_VERSION" diff --git a/src/deploy/k8s/set-ver.sh b/src/deploy/k8s/set-ver.sh index 927a207610..f5e3829dd4 100755 --- a/src/deploy/k8s/set-ver.sh +++ b/src/deploy/k8s/set-ver.sh @@ -1,9 +1,14 @@ #!/bin/bash +SCDIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") (return 0 2>/dev/null) && sourced=1 || sourced=0 if [ "$sourced" = "0" ]; then echo "This script must be invoked using: source $0 $*" exit 1 fi +if [ "$1" = "" ]; then + echo "Usage $0 [--release | --snapshot | --milestone] [--pro] [--skip-reg] [--namespace | -ns ] [postgres | postgresql | maria | mariadb | mysql | mysql57] [rabbit | rabbitmq | kafka] [prometheus | grafana]" + return 0 +fi METRICS= SKIP_REG= VERSION_FILE=$(realpath "$SCDIR/../versions.yaml") @@ -63,10 +68,10 @@ while [ "$1" != "" ]; do esac shift done -echo "Namespace: $NS" if [ "$NS" = "" ]; then NS=scdf fi +echo "Namespace: $NS" export NS if [ "$BROKER" != "" ]; then echo "BROKER: $BROKER" @@ -89,10 +94,10 @@ if [ "$DATAFLOW_VERSION" = "" ] || [ "$FORCE_VERSION" = "true" ]; then export DATAFLOW_PRO_VERSION DATAFLOW_VERSION=$(cat $VERSION_FILE | yq ".scdf-type.oss.${VERSION_TYPE}") else - DATAFLOW_VERSION=$(cat $VERSION_FILE | yq ".scdf-type.${SCDF_TYPE}.${VERSION_TYPE}") + DATAFLOW_VERSION=$(cat $VERSION_FILE | yq ".scdf-type.oss.${VERSION_TYPE}") fi - export DATAFLOW_VERSION SKIPPER_VERSION=$DATAFLOW_VERSION + export DATAFLOW_VERSION export SKIPPER_VERSION echo "DATAFLOW_VERSION: $DATAFLOW_VERSION" echo "SKIPPER_VERSION: $SKIPPER_VERSION" diff --git a/src/deploy/k8s/use-gke.sh b/src/deploy/k8s/use-gke.sh index 069891df54..7f943ac444 100755 --- a/src/deploy/k8s/use-gke.sh +++ b/src/deploy/k8s/use-gke.sh @@ -25,13 +25,5 @@ export KUBECONFIG=$HOME/.kube/config-gke gcloud container clusters get-credentials $GKE_CLUSTER --region $REGION echo "KUBECONFIG set to $KUBECONFIG" shift -if [ "$1" != "" ]; then - export NS=$1 - shift -fi -if [ "$NS" = "" ]; then - export NS=scdf -fi -echo "Namespace: $NS" -source $SCDIR/set-ver.sh +source $SCDIR/set-ver.sh $* diff --git a/src/deploy/k8s/use-microk8s.sh b/src/deploy/k8s/use-microk8s.sh index bdd2d83483..4c0c5b97b4 100755 --- a/src/deploy/k8s/use-microk8s.sh +++ b/src/deploy/k8s/use-microk8s.sh @@ -15,12 +15,4 @@ microk8s config > $HOME/.kube/config export KUBECONFIG=$HOME/.kube/config echo "KUBECONFIG=$KUBECONFIG" export K8S_DRIVER=microk8s -if [ "$1" != "" ]; then - export NS=$1 - shift -fi -if [ "$NS" = "" ]; then - export NS=scdf -fi -echo "Namespace: $NS" -source $SCDIR/set-ver.sh +source $SCDIR/set-ver.sh $* diff --git a/src/deploy/k8s/use-mk.sh b/src/deploy/k8s/use-mk.sh index 86a2ff4bc2..380d04fea0 100755 --- a/src/deploy/k8s/use-mk.sh +++ b/src/deploy/k8s/use-mk.sh @@ -10,7 +10,7 @@ if [ -z "$BASH_VERSION" ]; then exit 0 fi if [ "$1" = "" ]; then - echo "Arguments [--namespace ] [database] [broker] [--pro] [--skip-reg] [--release] [--snapshot] [--milestone]" + echo "Arguments [--release | --snapshot | --milestone] [--pro] [--skip-reg] [--namespace | -ns ] [postgres | postgresql | maria | mariadb | mysql | mysql57] [rabbit | rabbitmq | kafka] [prometheus | grafana]" echo "Driver must be one of kind, Or a valid driver for minikube like kvm2, docker, vmware, virtualbox, podman, vmwarefusion, hyperkit" return 0 fi @@ -20,5 +20,5 @@ export K8S_DRIVER KUBECONFIG= export KUBECONFIG shift -source $SCDIR/set-ver.sh +source $SCDIR/set-ver.sh $* diff --git a/src/deploy/k8s/use-tmc.sh b/src/deploy/k8s/use-tmc.sh index 17015c3022..c03d5376fb 100755 --- a/src/deploy/k8s/use-tmc.sh +++ b/src/deploy/k8s/use-tmc.sh @@ -19,12 +19,4 @@ echo "Connecting to $TMC_CLUSTER" tmc cluster auth kubeconfig get $TMC_CLUSTER > $HOME/.kube/config export KUBECONFIG=$HOME/.kube/config shift -if [ "$1" != "" ]; then - export NS=$1 - shift -fi -if [ "$NS" = "" ]; then - export NS=scdf -fi -echo "Namespace: $NS" -source $SCDIR/set-ver.sh +source $SCDIR/set-ver.sh $*