Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 15 additions & 20 deletions scripts/minikube/setup_minikube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ setup_local_registry_and_custom_image() {
# Clean up any existing registry first
sudo podman rm -f registry 2>/dev/null || true

if ! sudo podman run -d -p 127.0.0.1:5000:5000 --name registry --restart=always docker.io/library/registry:2; then
if ! sudo podman run -d -p 127.0.0.1:5000:5000 --replace --name registry --restart=always docker.io/library/registry:2; then
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sometimes cleanup didn't work, so we should just replace the existing/running one

echo "❌ Failed to start local registry - trying alternative approach"
exit 1
fi
Expand All @@ -79,26 +79,23 @@ setup_local_registry_and_custom_image() {
echo "✅ Local registry already running"
fi

# Configure podman to trust local registry (rootful only since minikube uses sudo podman)
# Configure podman to trust local registry (use 127.0.0.1 to avoid IPv6 issues)
echo "Configuring registries.conf to trust local registry..."
sudo mkdir -p /root/.config/containers
sudo tee /root/.config/containers/registries.conf << 'EOF' >/dev/null
[[registry]]
location = "localhost:5000"
location = "127.0.0.1:5000"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some loopback misses from prior pr

insecure = true
EOF
echo "✅ Registry configuration created"

custom_image_tag="localhost:5000/kicbase:v0.0.48"
custom_image_tag="127.0.0.1:5000/kicbase:v0.0.48"
if curl -s --max-time 5 http://127.0.0.1:5000/v2/kicbase/tags/list | grep -q "v0.0.48"; then
echo "Custom kicbase image already exists in local registry"
return 0
fi

# Build custom kicbase image with crictl
echo "Building custom kicbase image with crictl for ppc64le..."

# Build custom kicbase image
mkdir -p "${PROJECT_DIR:-.}/scripts/minikube/kicbase"
cat > "${PROJECT_DIR:-.}/scripts/minikube/kicbase/Dockerfile" << 'EOF'
FROM gcr.io/k8s-minikube/kicbase:v0.0.48
Expand All @@ -122,7 +119,7 @@ EOF
if ! curl -s --max-time 5 http://127.0.0.1:5000/v2/_catalog >/dev/null 2>&1; then
echo "Registry not responding, restarting..."
sudo podman rm -f registry 2>/dev/null || true
sudo podman run -d -p 127.0.0.1:5000:5000 --name registry --restart=always docker.io/library/registry:2
sudo podman run -d -p 127.0.0.1:5000:5000 --replace --name registry --restart=always docker.io/library/registry:2
for _ in {1..15}; do
if curl -s --max-time 5 http://127.0.0.1:5000/v2/_catalog >/dev/null 2>&1; then
echo "Registry restarted successfully"
Expand All @@ -146,27 +143,25 @@ EOF
start_minikube_cluster() {
echo ">>> Starting minikube cluster with podman driver (rootful mode)..."

if "${PROJECT_DIR:-.}/bin/minikube" status &>/dev/null; then
echo "✅ Minikube is already running - verifying health..."
if "${PROJECT_DIR:-.}/bin/minikube" kubectl -- get nodes &>/dev/null; then
# Check rootful podman directly (minikube status checks wrong namespace)
if sudo podman ps --filter name=minikube --format '{{.Names}}' 2>/dev/null | grep -q '^minikube$'; then
echo "✅ Minikube container exists - verifying kubectl connectivity..."
if "${PROJECT_DIR:-.}/bin/minikube" kubectl -- get nodes &>/dev/null 2>&1; then
echo "✅ Minikube cluster is healthy - skipping setup"
return 0
else
echo "⚠️ Minikube running but unhealthy - will recreate"
echo "⚠️ Minikube container exists but kubectl not working - will recreate"
fi
fi

# Clean up any existing minikube state to avoid cached configuration issues
echo "Cleaning up any existing minikube state..."
if [[ -d ~/.minikube/machines/minikube ]]; then
echo "Removing ~/.minikube/machines/minikube directory..."
rm -rf ~/.minikube/machines/minikube
fi
sudo rm -rf ~/.minikube/machines/minikube 2>/dev/null || true
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we use sudo podman (rootful) we also need to ensure minikube gets cleaned up in root space

rm -rf ~/.minikube/machines/minikube 2>/dev/null || true

echo "Ensuring clean minikube state..."
sudo "${PROJECT_DIR:-.}/bin/minikube" delete 2>/dev/null || true
"${PROJECT_DIR:-.}/bin/minikube" delete 2>/dev/null || true

# Clean up stale podman volumes
echo "Cleaning up stale podman volumes..."
sudo podman volume rm -f minikube 2>/dev/null || true
sudo podman network rm -f minikube 2>/dev/null || true
Expand All @@ -179,8 +174,8 @@ start_minikube_cluster() {
if [[ "${ARCH}" == "ppc64le" ]]; then
echo "Using custom kicbase image for ppc64le with crictl..."

start_args+=("--base-image=localhost:5000/kicbase:v0.0.48")
start_args+=("--insecure-registry=localhost:5000")
start_args+=("--base-image=127.0.0.1:5000/kicbase:v0.0.48")
start_args+=("--insecure-registry=127.0.0.1:5000")
fi

echo "Starting minikube with args: ${start_args[*]}"
Expand Down
Loading