Skip to content

Commit

Permalink
[CI] Improve k8s setup scripts. (#5942)
Browse files Browse the repository at this point in the history
  • Loading branch information
corneil authored Sep 27, 2024
1 parent d119ee4 commit 1297af7
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 32 deletions.
2 changes: 2 additions & 0 deletions src/deploy/k8s/configure-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 8 additions & 3 deletions src/deploy/k8s/set-ver.sh
Original file line number Diff line number Diff line change
@@ -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 <namespace> | -ns <namespace>] [postgres | postgresql | maria | mariadb | mysql | mysql57] [rabbit | rabbitmq | kafka] [prometheus | grafana]"
return 0
fi
METRICS=
SKIP_REG=
VERSION_FILE=$(realpath "$SCDIR/../versions.yaml")
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
10 changes: 1 addition & 9 deletions src/deploy/k8s/use-gke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $*

10 changes: 1 addition & 9 deletions src/deploy/k8s/use-microk8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $*
4 changes: 2 additions & 2 deletions src/deploy/k8s/use-mk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [ -z "$BASH_VERSION" ]; then
exit 0
fi
if [ "$1" = "" ]; then
echo "Arguments <driver> [--namespace <namespace>] [database] [broker] [--pro] [--skip-reg] [--release] [--snapshot] [--milestone]"
echo "Arguments <driver> [--release | --snapshot | --milestone] [--pro] [--skip-reg] [--namespace <namespace> | -ns <namespace>] [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
Expand All @@ -20,5 +20,5 @@ export K8S_DRIVER
KUBECONFIG=
export KUBECONFIG
shift
source $SCDIR/set-ver.sh
source $SCDIR/set-ver.sh $*

10 changes: 1 addition & 9 deletions src/deploy/k8s/use-tmc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $*

0 comments on commit 1297af7

Please sign in to comment.