Minikube Documentation
Installing Minikube
Linux
- Download the Minikube binary:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
- Install Minikube:
sudo install minikube-linux-amd64 /usr/local/bin/minikube
- Verify the installation:
minikube version
macOS
- Install via Homebrew:
brew install minikube
- Verify the installation:
minikube version
Windows
- Install via Chocolatey:
choco install minikube
- Verify the installation:
minikube version
Using Add-ons
To enable or disable Minikube add-ons:
minikube addons enable <addon-name>
minikube addons disable <addon-name>
Updating Minikube
To update Minikube to the latest version:
minikube update-check
minikube upgrade
Working with Minikube
Accessing Services
To access a service in Minikube:
kubectl port-forward service/<service-name> <local-port>:<service-port>
Accessing Kubernetes Dashboard
Starting the Dashboard
To start the Kubernetes Dashboard:
minikube dashboard
This command will open the dashboard in your default web browser.
- Open the URL in your web browser.
Create a New Profile
To create a new Minikube profile:
minikube start -p <profile-name>
For example, to create a profile named dev-cluster
:
minikube start -p dev-cluster
This command initializes a new cluster under the specified profile.
List Minikube Profiles
To list all profiles on your system:
minikube profile list
This will display all active profiles, along with their statuses and configuration details.
Switch Between Profiles
To switch to a different profile:
minikube profile <profile-name>
For example, to switch to the dev-cluster
profile:
minikube profile dev-cluster
Delete a Profile
To delete a specific profile:
minikube delete -p <profile-name>
For example, to delete the dev-cluster
profile:
minikube delete -p dev-cluster
Custom Minikube Configurations
Minikube allows you to persistently or temporarily configure your cluster with custom settings, such as resource limits, network configurations, and more.
Persistent Configurations
You can persistently set configurations that apply to all Minikube clusters using the minikube config
command.
Set Default Driver:
minikube config set driver docker
Set Default Memory and CPU:
minikube config set memory 8192
minikube config set cpus 4
This will ensure that all future Minikube clusters are created with 8GB of RAM and 4 CPUs by default.
Temporary Configurations
You can also set configurations for a specific session by passing flags to the minikube start
command.
Example of Temporary Configuration:
minikube start --memory 4096 --cpus 2
This will only apply to the session where the cluster is started.
Setting Resource Limits
To limit resource usage, use the following options during cluster startup:
-
Custom Disk Size:
minikube start --disk-size=30g
-
Limit CPU and Memory:
minikube start --cpus=3 --memory=6144
Networking Configurations
Accessing Minikube from Another Device
To make your Minikube cluster accessible from other devices on your local network, you need to expose Minikube’s IP:
-
Find the Minikube IP:
minikube ip
-
Use port forwarding to expose services externally.
Exposing Services to External Traffic
To expose a Kubernetes service to external traffic, use the LoadBalancer
service type. Here's an example YAML file for a service:
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 80
selector:
app: nginx
Apply this service with kubectl
:
kubectl apply -f nginx-service.yaml
Mounting Directories from Host
Minikube allows you to mount directories from your local machine into the Minikube VM or container.
Mount a Directory:
minikube mount /local/directory:/mountpoint
For example:
minikube mount ~/my-project:/app
This command will mount your ~/my-project
directory to /app
inside the Minikube VM or container.
Minikube Disk and Resource Management
You can dynamically manage resources allocated to Minikube:
Increase Disk Size:
minikube start --disk-size=50g
Increase CPU and Memory on Running Minikube:
You cannot change CPU and memory for an already running cluster, but you can stop Minikube and restart with new resources:
minikube stop
minikube start --cpus=4 --memory=8192
Minikube Logs and Debugging
Logs are critical for diagnosing issues with Minikube.
View Minikube Logs:
minikube logs
Enable Verbose Logging:
For detailed debugging information, you can start Minikube with verbose logging:
minikube start --v=7 --alsologtostderr
Essential Advanced Commands
Pause Minikube
To pause the Kubernetes cluster and free up system resources:
minikube pause
Unpause Minikube
To resume a paused Minikube cluster:
minikube unpause
Restart Minikube
If you need to restart the Minikube cluster:
minikube stop
minikube start
Minikube Service Management
To open a service in the default web browser:
minikube service <service-name>
For example:
minikube service nginx-service
To get the service URL without opening the browser:
minikube service <service-name> --url