#!/usr/bin/env bash if kubectl -n cert-manager get pods 2>/dev/null | grep -q 'Running'; then echo "cert-manager pods already running. Skipping installation." exit 0 fi kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.17.2/cert-manager.yaml echo "Waiting for cert-manager pods to be in 'Running' state..." MAX_RETRIES=10 RETRY=0 while [ $RETRY -lt $MAX_RETRIES ]; do NOT_READY_PODS=$(kubectl -n cert-manager get pods --no-headers | grep -v 'Running' | wc -l) if [ "$NOT_READY_PODS" -eq 0 ]; then echo "All cert-manager pods are running." break else echo "$NOT_READY_PODS pods are not ready yet. Waiting..." RETRY=$((RETRY + 1)) sleep 5 fi done if [ "$NOT_READY_PODS" -ne 0 ]; then echo "Failed to get all cert-manager pods running after $MAX_RETRIES attempts." exit 1 fi