In this lesson, we will learn how to set up a local Kubernetes environment using Minikube. Minikube is a tool that makes it easy to run Kubernetes locally. It runs a single-node Kubernetes cluster in a virtual machine on your laptop.
Before we begin, ensure you have the following installed: - Virtualization software (e.g., VirtualBox, VMware, or HyperKit) - kubectl: The Kubernetes command-line tool - Minikube: The tool to run Kubernetes locally
To install Minikube, follow the steps below based on your operating system:
brew install minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
Once Minikube is installed, you can start your local Kubernetes cluster with the following command:
minikube start
This command will download the necessary images and start a single-node Kubernetes cluster. You should see output indicating that Minikube is running.
To check the status of your Minikube cluster, run:
minikube status
You should see output indicating that the cluster is running, along with other details.
After starting Minikube, you can use kubectl to interact with your cluster. To verify that kubectl is configured correctly, run:
kubectl get nodes
You should see a single node listed as minikube.
Here are some common commands you will use with Minikube:
| Command | Description |
|-----------------------------|-----------------------------------------------|
| minikube start | Starts your Minikube cluster |
| minikube stop | Stops the Minikube cluster |
| minikube delete | Deletes the Minikube cluster |
| kubectl get pods | Lists all pods in the current namespace |
| kubectl apply -f <file> | Applies a configuration from a file |
Note: Always ensure that your Minikube is up to date to avoid compatibility issues with Kubernetes features.
Tip: Use the
--driverflag withminikube startto specify your virtualization driver. For example,minikube start --driver=virtualbox.
kubectl commands.--memory and --cpus flags when starting Minikube.In this lesson, you learned how to set up a local Kubernetes environment using Minikube. You can now start experimenting with Kubernetes by deploying applications locally.
minikube start to start your local Kubernetes cluster.minikube status.kubectl get nodes to list the nodes in your cluster.minikube node listed.minikube stop, and then restart it with minikube start.kubectl to interact with your Minikube cluster.