Setting up Minikube
Learning objectives
- You know how to set up Minikube.
Installing Minikube
Minikube allows quickly setting up a local Kubernetes cluster that can be used for development and testing. It is available for Linux, macOS, and Windows. Start by visiting the Minikube installation page and following the instructions for your operating system.
Note that the installation guidelines are different for each operating system. Running Minikube with WSL2 requires additional steps -- as a starting point, see e.g. https://gist.github.com/wholroyd/748e09ca0b78897750791172b2abb051 and https://github.com/cheslijones/wsl2-minikube).
For example, in Linux, we would use the binary installation method as presented on the page:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 77.3M 100 77.3M 0 0 5040k 0 0:00:15 0:00:15 --:--:-- 5050k
sudo install minikube-linux-amd64 /usr/local/bin/minikube
[sudo] password for user: (your password)
Once done, we can run the minikube version
command to check whether the installation was successful. The command outputs the version of the installed Minikube.
minikube version
minikube version: v1.29.0
commit: ddac20b4b34a9c8c857fc602203b6ba2679794d3
The following instructions outline working with Minikube on Linux. If you are using a different operating system, please refer to the Minikube documentation.
Starting and stopping a Minikube cluster
To start a Minikube cluster, we use the minikube start
command. The command starts a cluster with the default configuration (note that running the command for the first time can be slow as it downloads required images).
minikube start
😄 minikube v1.29.0 on Ubuntu 22.04
✨ Automatically selected the docker driver. Other choices: ssh, none
📌 Using Docker driver with root privileges
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
💾 Downloading Kubernetes v1.26.1 preload ...
> preloaded-images-k8s-v18-v1...: 397.05 MiB / 397.05 MiB 100.00% 2.49 Mi
> gcr.io/k8s-minikube/kicbase...: 407.19 MiB / 407.19 MiB 100.00% 2.56 Mi
🔥 Creating docker container (CPUs=2, Memory=7800MB) ...
🐳 Preparing Kubernetes v1.26.1 on Docker 20.10.23 ...
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔗 Configuring bridge CNI (Container Networking Interface) ...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🔎 Verifying Kubernetes components...
🌟 Enabled addons: storage-provisioner, default-storageclass
💡 kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
To stop the cluster, we run the minikube stop
command. The command stops the cluster, but does not delete it.
minikube stop
✋ Stopping node "minikube" ...
🛑 Powering off "minikube" via SSH ...
🛑 1 node stopped.
Installing kubectl
In the above output, when starting Minikube, we saw the message kubectl
not found -- kubectl
is a command-line tool for interacting with the Kubernetes cluster. To install kubectl
, follow the kubectl
related installation instructions on the Kubernetes Install Tools documentation.
You can skip this step if you wish and use
kubectl
through Minikube. The commandminikube kubectl -- <command>
would runkubectl
, giving it<command>
as the command. For exampleminikube kubectl -- get nodes
would list nodes in the Minikube cluster.
In the subsequent examples, we assume that you have installed kubectl
, have created an alias for kubectl
(as outlined in Minikube documentation), or are using minikube kubectl
.
Starting Minikube again
Now, when kubectl
is installed, we can start minikube again. This time, when running the command minikube start
, the output is as follows.
minikube start
😄 minikube v1.29.0 on Ubuntu 22.04
✨ Using the docker driver based on existing profile
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
🔄 Restarting existing docker container for "minikube" ...
🐳 Preparing Kubernetes v1.26.1 on Docker 20.10.23 ...
🔗 Configuring bridge CNI (Container Networking Interface) ...
🔎 Verifying Kubernetes components...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: storage-provisioner, default-storageclass
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
As we notice, the output also states that kubectl
is now configured to use the cluster. Now, when we run the command kubectl get pods
-- asking for the pods in the current namespace -- we see that no pods have been deployed.
kubectl get pods
No resources found in default namespace.
The default namespace is the namespace that is used when we do not explicitly specify a namespace. We'll continue using the default namespace for now.