Local Kubernetes Development: A Guide to Using Minikube
Learn how to develop and test your Kubernetes applications locally with Minikube. Our comprehensive guide walks you through installation, setting up the dashboard, and deploying sample applications.
Kubernetes has emerged as a leading open-source platform for container orchestration, designed for automating software deployment, scaling, and management. In enterprises, it’s often used for horizontally scaling server resources. Before deploying Kubernetes in production, it’s advisable to test the configuration. Minikube comes into play here—a tool created by Kubernetes developers to simulate a local Kubernetes cluster environment on a single machine.
Prerequisites
Before you begin, you should be familiar with Kubernetes basics. You’ll also need Docker, Homebrew (if you’re using macOS or Linux), and sufficient resources on your computer.
brew install minikube
Step 1: Installing and Running Minikube
You can install Minikube via Homebrew (on macOS or Linux) or through the official documentation for Windows. Once Minikube is installed, start it with the command `minikube start` to create a local Kubernetes cluster environment.
minikube start
Part 2: Accessing the Kubernetes Dashboard
Minikube offers a Kubernetes dashboard by default, allowing you to monitor your cluster and manually deploy applications. You can launch the dashboard with the command `minikube dashboard`.
minikube dashboard
Part 3: Deploying and Testing a Sample Application
You can deploy a test application on your Minikube cluster using the command `kubectl create deployment`. In this tutorial, we’ll use Google’s “hello-app” example. Once the app is deployed, you can access and test it via Minikube.
kubectl create deployment web –image=gcr.io/google-samples/hello-app:1.0
kubectl expose deployment web –type=NodePort –port=8080
minikube service web –url
Part 4: Managing Minikube Resources and Filesystem
Minikube offers various commands to manage your cluster. For instance, you can modify resource configuration with `minikube config` or mount local directories to the cluster with `minikube mount`.
minikube config set memory 4096
minikube delete
minikube start
minikube mount $HOME:/host
Part 5: (Optional) Working with Multiple Kubernetes Clusters
Minikube allows managing multiple profiles to work with different Kubernetes versions. You can create, switch, and configure profiles to navigate between clusters.
minikube start -p new-profile
minikube profile new-profile
minikube config get profile
Conclusion
Using Minikube for local development and testing offers a convenient way to develop and test Kubernetes applications before going to production. By following the steps presented in this tutorial, you can expand your Kubernetes knowledge and ensure your applications run smoothly.
While this tutorial covers basic steps for using Minikube, there are many more advanced features and best practices to discover. We recommend exploring additional Kubernetes tutorials to further enhance your skills and unlock the full potential of Minikube. Local Kubernetes Development: A Guide to Using Minikube