|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +# Define log file for debugging |
| 5 | +LOG_FILE=".github/e2e_tests/artifacts/logs/kind_cluster_logs/cosi_deployment/setup_debug.log" |
| 6 | +mkdir -p "$(dirname "$LOG_FILE")" # Ensure the log directory exists |
| 7 | + |
| 8 | +# Error handling function |
| 9 | +error_handler() { |
| 10 | + echo "An error occurred during the COSI setup. Check the log file for details." | tee -a "$LOG_FILE" |
| 11 | + echo "Failed command: $BASH_COMMAND" | tee -a "$LOG_FILE" |
| 12 | + exit 1 |
| 13 | +} |
| 14 | + |
| 15 | +# Trap errors and call the error handler |
| 16 | +trap 'error_handler' ERR |
| 17 | + |
| 18 | +# Log command execution to the log file for debugging |
| 19 | +log_and_run() { |
| 20 | + echo "Running: $*" | tee -a "$LOG_FILE" |
| 21 | + "$@" | tee -a "$LOG_FILE" |
| 22 | +} |
| 23 | + |
| 24 | +# Step 1: Install COSI CRDs |
| 25 | +log_and_run echo "Installing COSI CRDs..." |
| 26 | +log_and_run kubectl create -k github.com/kubernetes-sigs/container-object-storage-interface-api |
| 27 | +log_and_run kubectl create -k github.com/kubernetes-sigs/container-object-storage-interface-controller |
| 28 | + |
| 29 | +# Step 2: Verify COSI Controller Pod Status |
| 30 | +log_and_run echo "Verifying COSI Controller Pod status..." |
| 31 | +log_and_run kubectl wait --namespace default --for=condition=ready pod -l app.kubernetes.io/name=container-object-storage-interface-controller --timeout=10s |
| 32 | +log_and_run kubectl get pods --namespace default |
| 33 | + |
| 34 | +# Step 3: Build COSI driver Docker image |
| 35 | +log_and_run echo "Building COSI driver image..." |
| 36 | +log_and_run docker build -t ghcr.io/scality/cosi:latest . |
| 37 | + |
| 38 | +# Step 4: Load COSI driver image into KIND cluster |
| 39 | +log_and_run echo "Loading COSI driver image into KIND cluster..." |
| 40 | +log_and_run kind load docker-image ghcr.io/scality/cosi:latest --name object-storage-cluster |
| 41 | + |
| 42 | +# Step 5: Run COSI driver |
| 43 | +log_and_run echo "Applying COSI driver manifests..." |
| 44 | +log_and_run kubectl apply -k . |
| 45 | + |
| 46 | +# Step 6: Verify COSI driver Pod Status |
| 47 | +log_and_run echo "Verifying COSI driver Pod status..." |
| 48 | +log_and_run kubectl wait --namespace scality-object-storage --for=condition=ready pod --selector=app.kubernetes.io/name=scality-cosi-driver --timeout=20s |
| 49 | +log_and_run kubectl get pods -n scality-object-storage |
| 50 | + |
| 51 | +log_and_run echo "COSI setup completed successfully." |
0 commit comments