Skip to content

Commit 60e4fa0

Browse files
committed
Created a setup-minikube action
1 parent 64dc8bb commit 60e4fa0

2 files changed

Lines changed: 296 additions & 0 deletions

File tree

setup-minikube/README.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Setup Minikube Action
2+
3+
This GitHub Action sets up a Minikube cluster with optional Ingress and OLM (Operator Lifecycle Manager) support.
4+
5+
## Features
6+
7+
- 🚀 Sets up Minikube with configurable versions
8+
- 🌐 Optional Ingress controller installation
9+
- 📦 Optional OLM installation for operator management
10+
- 🔧 Automatic port-forwarding setup
11+
- 🌉 Background tunnel setup for LoadBalancer services
12+
- ✅ Comprehensive verification and status reporting
13+
14+
## Usage
15+
16+
### Basic Setup
17+
18+
```yaml
19+
- name: Setup Minikube
20+
uses: Apicurio/apicurio-github-actions/setup-minikube@main
21+
```
22+
23+
### With Ingress
24+
25+
```yaml
26+
- name: Setup Minikube with Ingress
27+
uses: Apicurio/apicurio-github-actions/setup-minikube@main
28+
with:
29+
ingress-enable: 'true'
30+
```
31+
32+
### With OLM
33+
34+
```yaml
35+
- name: Setup Minikube with OLM
36+
uses: Apicurio/apicurio-github-actions/setup-minikube@main
37+
with:
38+
olm-enable: 'true'
39+
olm-version: '0.32.0'
40+
```
41+
42+
### Full Configuration
43+
44+
```yaml
45+
- name: Setup Minikube
46+
uses: Apicurio/apicurio-github-actions/setup-minikube@main
47+
with:
48+
ingress-enable: 'true'
49+
olm-enable: 'true'
50+
olm-version: '0.32.0'
51+
minikube-version: 'v1.36.0'
52+
kubernetes-version: 'v1.33.3'
53+
driver: 'docker'
54+
start-args: '--force --memory=4096'
55+
```
56+
57+
## Inputs
58+
59+
| Input | Description | Required | Default |
60+
|-------|-------------|----------|---------|
61+
| `ingress-enable` | Install an Ingress controller | No | `false` |
62+
| `olm-enable` | Install OLM | No | `false` |
63+
| `olm-version` | OLM version to install | No | `0.32.0` |
64+
| `minikube-version` | Minikube version to use | No | `v1.36.0` |
65+
| `kubernetes-version` | Kubernetes version to use | No | `v1.33.3` |
66+
| `driver` | Minikube driver to use | No | `docker` |
67+
| `start-args` | Additional arguments to pass to minikube start | No | `--force` |
68+
69+
## Outputs
70+
71+
| Output | Description |
72+
|--------|-------------|
73+
| `minikube-status` | Status of the Minikube cluster |
74+
| `kubernetes-version` | Version of Kubernetes running in Minikube |
75+
| `cluster-ip` | IP address of the Minikube cluster |
76+
77+
## Example Workflow
78+
79+
```yaml
80+
name: Test with Minikube
81+
on: [push, pull_request]
82+
83+
jobs:
84+
test:
85+
runs-on: ubuntu-latest
86+
steps:
87+
- name: Checkout
88+
uses: actions/checkout@v4
89+
90+
- name: Setup Minikube
91+
id: minikube
92+
uses: Apicurio/apicurio-github-actions/setup-minikube@main
93+
with:
94+
ingress-enable: 'true'
95+
olm-enable: 'true'
96+
97+
- name: Deploy application
98+
run: |
99+
kubectl apply -f k8s/
100+
kubectl wait --for=condition=ready pod -l app=myapp --timeout=300s
101+
102+
- name: Test application
103+
run: |
104+
echo "Cluster IP: ${{ steps.minikube.outputs.cluster-ip }}"
105+
echo "Kubernetes version: ${{ steps.minikube.outputs.kubernetes-version }}"
106+
# Run your tests here
107+
```
108+
109+
## What This Action Does
110+
111+
1. **Port-forwarding Setup**: Installs `socat` for proper port-forwarding support
112+
2. **Minikube Installation**: Uses the `manusa/actions-setup-minikube` action to install and start Minikube
113+
3. **Cluster Information**: Retrieves and outputs cluster status, Kubernetes version, and cluster IP
114+
4. **Ingress Setup** (optional): Enables the Ingress addon and waits for the controller to be ready
115+
5. **OLM Installation** (optional): Downloads and installs the specified version of OLM
116+
6. **Tunnel Setup**: Starts a Minikube tunnel in the background for LoadBalancer service access
117+
7. **Verification**: Verifies the setup by checking kubectl connectivity and listing system resources
118+
119+
## Notes
120+
121+
- The Minikube tunnel runs in the background for the duration of the job, enabling access to LoadBalancer services
122+
- When Ingress is enabled, the action waits for the Ingress controller to be ready before proceeding
123+
- When OLM is enabled, the action waits for both the OLM operator and catalog operator to be ready
124+
- The action provides comprehensive logging with emojis for easy identification of different steps
125+
- All timeouts are set to 300 seconds (5 minutes) to allow for slower environments
126+
127+
## Requirements
128+
129+
- Runs on Ubuntu runners (uses `apt-get` for package installation)
130+
- Requires Docker to be available (default driver is `docker`)
131+
- Internet access for downloading Minikube, Kubernetes, and OLM components

setup-minikube/action.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
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

Comments
 (0)