|
| 1 | +name: 'Setup Minikube' |
| 2 | +description: 'Setup Minikube with optional Ingress and OLM support' |
| 3 | +author: 'Apicurio' |
| 4 | +branding: |
| 5 | + icon: 'server' |
| 6 | + color: 'purple' |
| 7 | + |
| 8 | +inputs: |
| 9 | + ingress-enable: |
| 10 | + description: 'Install an Ingress controller' |
| 11 | + required: false |
| 12 | + default: 'false' |
| 13 | + olm-enable: |
| 14 | + description: 'Install OLM' |
| 15 | + required: false |
| 16 | + default: 'false' |
| 17 | + olm-version: |
| 18 | + description: 'OLM version to install' |
| 19 | + required: false |
| 20 | + default: '0.32.0' |
| 21 | + minikube-version: |
| 22 | + description: 'Minikube version to use' |
| 23 | + required: false |
| 24 | + default: 'v1.36.0' |
| 25 | + kubernetes-version: |
| 26 | + description: 'Kubernetes version to use' |
| 27 | + required: false |
| 28 | + default: 'v1.33.3' |
| 29 | + driver: |
| 30 | + description: 'Minikube driver to use' |
| 31 | + required: false |
| 32 | + default: 'docker' |
| 33 | + start-args: |
| 34 | + description: 'Additional arguments to pass to minikube start' |
| 35 | + required: false |
| 36 | + default: '--force' |
| 37 | + |
| 38 | +outputs: |
| 39 | + minikube-status: |
| 40 | + description: 'Status of the Minikube cluster' |
| 41 | + value: ${{ steps.setup-minikube.outputs.minikube-status }} |
| 42 | + kubernetes-version: |
| 43 | + description: 'Version of Kubernetes running in Minikube' |
| 44 | + value: ${{ steps.setup-minikube.outputs.kubernetes-version }} |
| 45 | + cluster-ip: |
| 46 | + description: 'IP address of the Minikube cluster' |
| 47 | + value: ${{ steps.setup-minikube.outputs.cluster-ip }} |
| 48 | + |
| 49 | +runs: |
| 50 | + using: 'composite' |
| 51 | + steps: |
| 52 | + - name: Enable port-forwarding |
| 53 | + shell: bash |
| 54 | + run: | |
| 55 | + echo "🔧 Installing socat for port-forwarding..." |
| 56 | + sudo apt-get update -qq |
| 57 | + sudo apt-get -y install socat |
| 58 | + echo "✅ Port-forwarding support enabled" |
| 59 | +
|
| 60 | + - name: Setup Minikube |
| 61 | + id: setup-minikube |
| 62 | + uses: manusa/actions-setup-minikube@v2.13.0 |
| 63 | + with: |
| 64 | + driver: ${{ inputs.driver }} |
| 65 | + minikube version: ${{ inputs.minikube-version }} |
| 66 | + kubernetes version: ${{ inputs.kubernetes-version }} |
| 67 | + start args: ${{ inputs.start-args }} |
| 68 | + |
| 69 | + - name: Get Minikube Status |
| 70 | + id: minikube-info |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + echo "📊 Getting Minikube cluster information..." |
| 74 | + |
| 75 | + # Get Minikube status |
| 76 | + MINIKUBE_STATUS=$(minikube status --format='{{.Host}}' 2>/dev/null || echo "unknown") |
| 77 | + echo "minikube-status=${MINIKUBE_STATUS}" >> $GITHUB_OUTPUT |
| 78 | + echo "🔍 Minikube status: ${MINIKUBE_STATUS}" |
| 79 | + |
| 80 | + # Get Kubernetes version |
| 81 | + K8S_VERSION=$(kubectl version --short --client=false 2>/dev/null | grep "Server Version" | awk '{print $3}' || echo "unknown") |
| 82 | + echo "kubernetes-version=${K8S_VERSION}" >> $GITHUB_OUTPUT |
| 83 | + echo "🔍 Kubernetes version: ${K8S_VERSION}" |
| 84 | + |
| 85 | + # Get cluster IP |
| 86 | + CLUSTER_IP=$(minikube ip 2>/dev/null || echo "unknown") |
| 87 | + echo "cluster-ip=${CLUSTER_IP}" >> $GITHUB_OUTPUT |
| 88 | + echo "🔍 Cluster IP: ${CLUSTER_IP}" |
| 89 | + |
| 90 | + # Display cluster info |
| 91 | + echo "" |
| 92 | + echo "📋 Cluster Information:" |
| 93 | + kubectl cluster-info || echo "⚠️ Could not retrieve cluster info" |
| 94 | +
|
| 95 | + - name: Enable Ingress |
| 96 | + if: inputs.ingress-enable == 'true' |
| 97 | + shell: bash |
| 98 | + run: | |
| 99 | + echo "🚀 Enabling Ingress addon..." |
| 100 | + minikube addons enable ingress |
| 101 | + |
| 102 | + echo "⏳ Waiting for Ingress controller to be ready..." |
| 103 | + kubectl wait --namespace ingress-nginx \ |
| 104 | + --for=condition=ready pod \ |
| 105 | + --selector=app.kubernetes.io/component=controller \ |
| 106 | + --timeout=300s || echo "⚠️ Ingress controller may not be fully ready" |
| 107 | + |
| 108 | + echo "✅ Ingress addon enabled" |
| 109 | +
|
| 110 | + - name: Install OLM |
| 111 | + if: inputs.olm-enable == 'true' |
| 112 | + shell: bash |
| 113 | + run: | |
| 114 | + echo "🚀 Installing OLM (Operator Lifecycle Manager)..." |
| 115 | + echo "📦 OLM Version: ${{ inputs.olm-version }}" |
| 116 | + |
| 117 | + # Download and install OLM |
| 118 | + curl -L https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v${{ inputs.olm-version }}/install.sh -o install-olm.sh |
| 119 | + chmod +x install-olm.sh |
| 120 | + ./install-olm.sh v${{ inputs.olm-version }} |
| 121 | + rm install-olm.sh |
| 122 | + |
| 123 | + echo "⏳ Waiting for OLM to be ready..." |
| 124 | + kubectl wait --for=condition=ready pod -l app=olm-operator --namespace=olm --timeout=300s || echo "⚠️ OLM may not be fully ready" |
| 125 | + kubectl wait --for=condition=ready pod -l app=catalog-operator --namespace=olm --timeout=300s || echo "⚠️ Catalog operator may not be fully ready" |
| 126 | + |
| 127 | + echo "✅ OLM installation completed" |
| 128 | +
|
| 129 | + - name: Setup Minikube tunnel |
| 130 | + shell: bash |
| 131 | + run: | |
| 132 | + echo "🌐 Starting Minikube tunnel in background..." |
| 133 | + minikube tunnel & |
| 134 | + |
| 135 | + # Give the tunnel a moment to start |
| 136 | + sleep 5 |
| 137 | + |
| 138 | + echo "✅ Minikube tunnel started" |
| 139 | + echo "ℹ️ The tunnel will run in the background for the duration of this job" |
| 140 | +
|
| 141 | + - name: Verify Setup |
| 142 | + shell: bash |
| 143 | + run: | |
| 144 | + echo "🔍 Verifying Minikube setup..." |
| 145 | + |
| 146 | + # Check if kubectl is working |
| 147 | + if kubectl get nodes; then |
| 148 | + echo "✅ kubectl is working correctly" |
| 149 | + else |
| 150 | + echo "❌ kubectl is not working" |
| 151 | + exit 1 |
| 152 | + fi |
| 153 | + |
| 154 | + # List enabled addons |
| 155 | + echo "" |
| 156 | + echo "📋 Enabled addons:" |
| 157 | + minikube addons list | grep enabled || echo "No addons enabled" |
| 158 | + |
| 159 | + # Show running pods in system namespaces |
| 160 | + echo "" |
| 161 | + echo "📋 System pods:" |
| 162 | + kubectl get pods --all-namespaces --field-selector=status.phase=Running | head -10 |
| 163 | + |
| 164 | + echo "" |
| 165 | + echo "🎉 Minikube setup completed successfully!" |
0 commit comments