|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +kind create cluster --config kind.yaml |
| 4 | + |
| 5 | +kubectl apply -f https://github.com/cert-manager/cert-manager/releases/latest/download/cert-manager.yaml |
| 6 | + |
| 7 | +# Ensure that cert-manager is up and running |
| 8 | +echo "Waiting for cert-manager to be ready..." |
| 9 | + |
| 10 | +# Wait for cert-manager pods to be ready |
| 11 | +kubectl -n cert-manager wait --for=condition=Available deployment/cert-manager-webhook --timeout=300s |
| 12 | + |
| 13 | +# Create a test namespace for cert-manager readiness check |
| 14 | +kubectl create namespace cert-manager-test |
| 15 | + |
| 16 | +# Function to check cert-manager readiness with retries |
| 17 | +check_cert_manager_ready() { |
| 18 | + local max_attempts=30 |
| 19 | + local attempt=1 |
| 20 | + local sleep_time=10 |
| 21 | + |
| 22 | + while [ $attempt -le $max_attempts ]; do |
| 23 | + echo "Attempt $attempt/$max_attempts: Creating test Issuer and Certificate..." |
| 24 | + |
| 25 | + # Create a self-signed Issuer |
| 26 | + if kubectl apply -f - <<EOF |
| 27 | +apiVersion: cert-manager.io/v1 |
| 28 | +kind: Issuer |
| 29 | +metadata: |
| 30 | + name: test-selfsigned |
| 31 | + namespace: cert-manager-test |
| 32 | +spec: |
| 33 | + selfSigned: {} |
| 34 | +EOF |
| 35 | + then |
| 36 | + echo "Issuer created successfully" |
| 37 | + |
| 38 | + # Create a Certificate using the Issuer |
| 39 | + if kubectl apply -f - <<EOF |
| 40 | +apiVersion: cert-manager.io/v1 |
| 41 | +kind: Certificate |
| 42 | +metadata: |
| 43 | + name: test-certificate |
| 44 | + namespace: cert-manager-test |
| 45 | +spec: |
| 46 | + secretName: test-certificate-secret |
| 47 | + isCA: false |
| 48 | + dnsNames: |
| 49 | + - test.example.com |
| 50 | + issuerRef: |
| 51 | + name: test-selfsigned |
| 52 | + kind: Issuer |
| 53 | +EOF |
| 54 | + then |
| 55 | + echo "Certificate created successfully" |
| 56 | + |
| 57 | + # Wait for the Certificate to become ready |
| 58 | + if kubectl wait --for=condition=ready certificate/test-certificate -n cert-manager-test --timeout=60s 2>/dev/null; then |
| 59 | + echo "cert-manager is ready!" |
| 60 | + return 0 |
| 61 | + else |
| 62 | + echo "Certificate not ready yet, will retry..." |
| 63 | + fi |
| 64 | + else |
| 65 | + echo "Failed to create Certificate, webhook may not be ready yet..." |
| 66 | + fi |
| 67 | + else |
| 68 | + echo "Failed to create Issuer, webhook may not be ready yet..." |
| 69 | + fi |
| 70 | + |
| 71 | + # Clean up before retry |
| 72 | + kubectl delete certificate test-certificate -n cert-manager-test --ignore-not-found=true 2>/dev/null |
| 73 | + kubectl delete issuer test-selfsigned -n cert-manager-test --ignore-not-found=true 2>/dev/null |
| 74 | + |
| 75 | + attempt=$((attempt + 1)) |
| 76 | + if [ $attempt -le $max_attempts ]; then |
| 77 | + echo "Waiting ${sleep_time}s before retry..." |
| 78 | + sleep $sleep_time |
| 79 | + fi |
| 80 | + done |
| 81 | + |
| 82 | + echo "ERROR: cert-manager did not become ready after $max_attempts attempts" |
| 83 | + return 1 |
| 84 | +} |
| 85 | + |
| 86 | +# Run the readiness check |
| 87 | +if check_cert_manager_ready; then |
| 88 | + # Clean up test resources |
| 89 | + kubectl delete namespace cert-manager-test |
| 90 | +else |
| 91 | + # Clean up and exit with error |
| 92 | + kubectl delete namespace cert-manager-test |
| 93 | + exit 1 |
| 94 | +fi |
| 95 | + |
| 96 | + |
| 97 | +kubectl apply -f https://github.com/metal3-io/ironic-standalone-operator/releases/latest/download/install.yaml |
| 98 | + |
| 99 | +kubectl create ns baremetal-operator-system |
| 100 | + |
| 101 | +kubectl apply -f ironic.yaml |
| 102 | +kubectl apply -k bmo |
0 commit comments