DEV Community

cloud-sky-ops
cloud-sky-ops

Posted on • Edited on

Running minikube in GitHub Workflow: A Step-by-Step Guide

Introduction

Minikube is a great way to run Kubernetes locally, but ever wondered how to use it inside a GitHub Actions workflow? Running Minikube in CI/CD pipelines can be tricky, but thanks to a GitHub Marketplace action mentioned ahead, we can seamlessly deploy and test containerized applications in Minikube as part of an automated workflow.


Why Use Minikube in GitHub Actions?

✅ Run lightweight Kubernetes clusters on pre-defined events
✅ Test Kubernetes manifests before pushing to production
✅ Debug issues in a controlled Minikube environment
Visibility and log access to all team members

By integrating Minikube in GitHub Actions, you ensure that your Kubernetes deployments work flawlessly before merging changes.


Challenges & workarounds

Installing Minikube & Dependencies

Installing Minikube manually along with its dependencies (conntrack, iptables, socat, cri-dockerd, etc.) is complex. So instead, switch to using a pre-built Minikube action from the GitHub Marketplace:

- name: Start minikube
  uses: medyagh/setup-minikube@latest
Enter fullscreen mode Exit fullscreen mode

Fix: The official action, medyagh/setup-minikube, handles everything, eliminating manual installation errors.

Loading Docker Images into Minikube

Minikube runs in an isolated environment, so we must manually load our built Docker image:

- name: Load image to minikube
  run: minikube image load <IMAGE_NAME>
Enter fullscreen mode Exit fullscreen mode

Fix: minikube image load ensures the image is available inside the Minikube cluster. You can verify using the "minikube image ls" command.


** Using medyagh/setup-minikube GitHub Action**

Instead of manually installing Minikube and its dependencies, we can use medyagh/setup-minikube, an official GitHub Action that simplifies Minikube setup. (Minikube documentation)

Benefits of medyagh/setup-minikube

  • Quick Minikube installation with minimal setup.
  • Customizable Kubernetes versions, CPU, and memory configurations.
  • Supports multiple drivers (docker, none, etc.) for different environments.
  • Easier debugging and reliability within GitHub runners.

Customization Options

The medyagh/setup-minikube action provides several configuration options:

Parameter Description
minikube-version Specifies the Minikube version to install.
driver Defines the virtualization driver (e.g., docker, none).
container-runtime Sets the container runtime (docker, containerd).
kubernetes-version Specifies the Kubernetes version to deploy.
cpus Allocates the number of CPUs for the Minikube VM.
memory Allocates memory for Minikube.
addons Enables Minikube addons like ingress, dashboard.
extra-config Allows additional configurations for Kubernetes components.
wait Ensures Minikube is fully ready before proceeding.

Example Usage

- name: Start Minikube
  uses: medyagh/setup-minikube@latest
  with:
    minikube-version: '1.34.0'
    driver: 'docker'
    container-runtime: 'containerd'
    kubernetes-version: 'v1.32.0'
    cpus: '4'
    memory: '4000m'
    addons: 'ingress,dashboard'
Enter fullscreen mode Exit fullscreen mode

This sets up Minikube v1.34.0 using the Docker driver, 4 CPUs, 4GB RAM, and enables Ingress & Dashboard addons.


Best Practices for Running Minikube in GitHub Actions

Use a pre-built GitHub Action for Minikube instead of manual installation.
Load Docker images using **minikube image load** to make them available in the cluster.
Add logs & debugging steps (kubectl get all, kubectl describe pod, kubectl logs).
✅ Use *workflow_dispatch* and *push* triggers to control when the workflow runs.


🎯 Conclusion

Running Minikube in GitHub Action Workflows allows you to test Kubernetes deployments before merging changes, ensuring consistency and reliability. By leveraging the official Minikube GitHub Action you can access Minikube seamlessly.

Ready to try it? Checkout my implementation of the same on a sample node application here

Implement this in your GitHub Actions and drop your thoughts, comments and insights! 💡

Thank You.

Top comments (0)