Skip to content

Commit

Permalink
changed note, added fast launch script and local log file path
Browse files Browse the repository at this point in the history
  • Loading branch information
elankath committed Nov 21, 2024
1 parent 5cb92cf commit e2d8ff3
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions cluster-autoscaler/hack/launch-local-ca.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ echoErr() { echo "$@" 1>&2; }
CURRENT_DIR=$(pwd)
PROJECT_ROOT="${CURRENT_DIR}"

if ! command -v gum &>/dev/null; then
echoErr "gum not installed. Kindly first install gum (https://github.com/charmbracelet/gum) using relevant procedure for your OS"
exit 1
fi

devEnvFile="$PROJECT_ROOT/.env"
if [[ ! -f "$devEnvFile" ]]; then
echoErr "ERROR: $devEnvFile is not created. Kindly execute ./hack/local_setup.sh before running this script."
Expand Down Expand Up @@ -40,7 +35,7 @@ if [[ ! -f "main.go" ]]; then
exit 6
fi

echo "NOTE: This script generates a /tmp/local-ca.sh which launches the local CA with the same configuration as that of the remote CA in the configured shoot's control plane"
echo "NOTE: This script launches the local CA with the same configuration as that of the remote CA in the configured shoot's control plane"

echo "Targeting control plane of sap-landscape-dev:$GARDEN_PROJECT:$SHOOT"
gardenctl target --garden sap-landscape-dev --project "$GARDEN_PROJECT" --shoot aw --control-plane
Expand All @@ -52,7 +47,26 @@ commandArgs=$(jq -r '.spec.template.spec.containers[0].command[]' "$caDeploJsonP
export CONTROL_KUBECONFIG="$CONTROL_KUBECONFIG"
export CONTROL_NAMESPACE="$CONTROL_NAMESPACE"
export TARGET_KUBECONFIG="$TARGET_KUBECONFIG"
launchCommand="go run main.go --kubeconfig=$TARGET_KUBECONFIG $commandArgs 2>&1 | tee /tmp/ca.log"
gum confirm "Launch local CA using following command: '$launchCommand' ?" && echo "$launchCommand" && eval "$launchCommand"
launchCommand="go run main.go --kubeconfig=$TARGET_KUBECONFIG $commandArgs 2>&1 | tee /tmp/ca-local.log"
fastLaunchScript="/tmp/fast-launch-ca.sh"
echo


echo "Creating fast launch script at $fastLaunchScript"
cat << EOF >"$fastLaunchScript"
cd "$PROJECT_ROOT"
export CONTROL_KUBECONFIG="$CONTROL_KUBECONFIG"
export CONTROL_NAMESPACE="$CONTROL_NAMESPACE"
export TARGET_KUBECONFIG="$TARGET_KUBECONFIG"
echo "$launchCommand"
$launchCommand
EOF
chmod +x "$fastLaunchScript"


pauseSecs="5"
echo "Launching local CA using following command in $pauseSecs secs. You may also launch using generated fast launch script at: $fastLaunchScript "
echo "$launchCommand"
sleep "$pauseSecs"
eval "$launchCommand"

0 comments on commit e2d8ff3

Please sign in to comment.