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 upgradeWorking 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 dashboardThis 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-clusterThis command initializes a new cluster under the specified profile.
List Minikube Profiles
To list all profiles on your system:
minikube profile listThis 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-clusterDelete a Profile
To delete a specific profile:
minikube delete -p <profile-name>For example, to delete the dev-cluster profile:
minikube delete -p dev-clusterCustom 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 dockerSet Default Memory and CPU:
minikube config set memory 8192
minikube config set cpus 4This 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 2This 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: nginxApply this service with kubectl:
kubectl apply -f nginx-service.yamlMounting 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:/mountpointFor example:
minikube mount ~/my-project:/appThis 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=50gIncrease 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=8192Minikube Logs and Debugging
Logs are critical for diagnosing issues with Minikube.
View Minikube Logs:
minikube logsEnable Verbose Logging:
For detailed debugging information, you can start Minikube with verbose logging:
minikube start --v=7 --alsologtostderrEssential Advanced Commands
Pause Minikube
To pause the Kubernetes cluster and free up system resources:
minikube pauseUnpause Minikube
To resume a paused Minikube cluster:
minikube unpauseRestart Minikube
If you need to restart the Minikube cluster:
minikube stop
minikube startMinikube Service Management
To open a service in the default web browser:
minikube service <service-name>For example:
minikube service nginx-serviceTo get the service URL without opening the browser:
minikube service <service-name> --url