From b1130581688174290e0a42a407375191eb77e30a Mon Sep 17 00:00:00 2001 From: Gyanendra Mishra Date: Thu, 11 Jul 2024 13:48:15 +0100 Subject: [PATCH] fix: use curl to install and fix wording in forward.sh (#11) * fix forwarding * drop docker infavor of curl install ofcli * cleanup * fix this * fix install --- scripts/forward.sh | 4 +-- scripts/startup.sh | 69 ++++++++++++++-------------------------------- 2 files changed, 22 insertions(+), 51 deletions(-) diff --git a/scripts/forward.sh b/scripts/forward.sh index 6cb530b..ed53955 100755 --- a/scripts/forward.sh +++ b/scripts/forward.sh @@ -30,13 +30,13 @@ retry_with_exponential_backoff() { if eval "$cmd"; then return 0 fi - echo "Command failed. Retrying in $retry_delay seconds..." + echo "Port forwarding failed. Retrying in $retry_delay seconds..." sleep $retry_delay retry_delay=$((retry_delay * 2)) ((retries++)) done - echo "Max retries reached. Command failed." + echo "Max retries reached. Port forwarding failed." return 1 } diff --git a/scripts/startup.sh b/scripts/startup.sh index 5c87c58..c751c6f 100755 --- a/scripts/startup.sh +++ b/scripts/startup.sh @@ -86,28 +86,22 @@ install_istio() { setup_kardinal_cli() { log "🛠️ Setting up Kardinal CLI..." - # Pull the Kardinal CLI image - run_command_with_spinner docker pull kurtosistech/kardinal-cli || log_error "Failed to pull Kardinal CLI image" - - # Find the kardinal.cli binary path - KARDINAL_CLI_PATH=$(docker run --rm kurtosistech/kardinal-cli sh -c 'ls -1 /nix/store/*/bin/kardinal.cli 2>/dev/null | head -n 1') - - if [ -z "$KARDINAL_CLI_PATH" ]; then - log_error "Failed to find kardinal.cli binary in the Docker image" - return 1 - fi + # Install Kardinal CLI using curl + run_command_with_spinner sh -c 'curl get.kardinal.dev -sL | bash' || log_error "Failed to install Kardinal CLI" # Ensure the Kardinal data directory exists mkdir -p "$KARDINAL_DATA_DIR" - # Update the alias to use the correct data directory - alias kardinal="docker run --rm -it -v \${PWD}:/workdir -v /var/run/docker.sock:/var/run/docker.sock -v $KARDINAL_DATA_DIR:/.local/share/kardinal -w /workdir --network host --entrypoint $KARDINAL_CLI_PATH kurtosistech/kardinal-cli" + # Find the kardinal CLI path + KARDINAL_CLI_PATH=$(which kardinal) - # Add the updated alias to .bashrc for persistence - echo "alias kardinal=\"docker run --rm -it -v \${PWD}:/workdir -v /var/run/docker.sock:/var/run/docker.sock -v $KARDINAL_DATA_DIR:/.local/share/kardinal -w /workdir --network host --entrypoint $KARDINAL_CLI_PATH kurtosistech/kardinal-cli\"" >> ~/.bashrc + if [ -z "$KARDINAL_CLI_PATH" ]; then + log_error "Failed to find kardinal CLI after installation" + return 1 + fi - log "✅ Kardinal CLI alias created. You can now use 'kardinal' command directly." - log_verbose "Kardinal CLI setup completed. The 'kardinal' command is now available." + log "✅ Kardinal CLI installed successfully. You can now use the 'kardinal' command directly." + log_verbose "Kardinal CLI setup completed. The 'kardinal' command is now available at $KARDINAL_CLI_PATH." } deploy_kardinal_manager() { @@ -128,49 +122,26 @@ deploy_kardinal_manager() { return 1 fi - log_verbose "About to run Docker command to deploy manager..." - - # Run the Docker command with spinner - run_command_with_spinner docker run --rm \ - -v ${PWD}:/workdir \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -v $KARDINAL_DATA_DIR:/.local/share/kardinal \ - -v $kube_config:/.kube/config \ - -v $minikube_dir:/home/codespace/.minikube \ - -e MINIKUBE_HOME=/home/codespace/.minikube \ - -w /workdir \ - --network host \ - --entrypoint $KARDINAL_CLI_PATH \ - kurtosistech/kardinal-cli manager deploy kloud-kontrol - - log_verbose "Docker command to deploy manager completed successfully" + log_verbose "About to run kardinal command to deploy manager..." + + # Run the kardinal command with spinner + run_command_with_spinner kardinal manager deploy kloud-kontrol + + log_verbose "Kardinal command to deploy manager completed successfully" log "👩‍💼 Kardinal Manager Deployed" - # Run the Docker command for voting app deployment with spinner - run_command_with_spinner docker run --rm \ - -v ${PWD}:/workdir \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -v $KARDINAL_DATA_DIR:/.local/share/kardinal \ - -v $kube_config:/.kube/config \ - -v $minikube_dir:/home/codespace/.minikube \ - -e MINIKUBE_HOME=/home/codespace/.minikube \ - -w /workdir \ - --network host \ - --entrypoint $KARDINAL_CLI_PATH \ - kurtosistech/kardinal-cli deploy -d voting-app-demo/compose.yml + # Run the kardinal command for voting app deployment with spinner + run_command_with_spinner kardinal deploy -d voting-app-demo/compose.yml log "🗳️ Initial version of voting app deployed" - # Extract the Tenant UUID from the UUID file - if [ -f "$UUID_FILE" ]; then - TENANT_UUID=$(cat "$UUID_FILE") - log_verbose "Using existing Tenant UUID: $TENANT_UUID" - else + if [ ! -f "$UUID_FILE" ]; then log_error "UUID file not found at $UUID_FILE after deployment" return 1 fi + TENANT_UUID=$(cat "$UUID_FILE") log_verbose "Kardinal Manager deployed successfully with Tenant UUID: $TENANT_UUID" }