How to Set Up a Kubernetes Cluster Locally on Windows Using Minikube and kubectl: A Step-by-Step Guide
Introduction
Kubernetes is an open-source, widely adopted container orchestration tool known for its powerful features, including autoscaling, load balancing, failover handling, and centralized logging. While other container orchestration tools are available, Kubernetes has become the de facto industry standard.
In this post, I will guide you through setting up Kubernetes locally, allowing you to explore some of its remarkable features firsthand.
Prerequisite
This guide focuses on setting up this on a Windows machine. To follow along, you should have the following:
- Hyper-V setup on your Windows 10
- Chocolatey installed — a Windows package manager which makes installing third-party tools very easy.
Step 1 — Install kubectl
kubectl
is a command-line tool that serves as the primary tool for interacting with a Kubernetes cluster.
- Open your command prompt and run as administrator.
- Verify you have
Chocolatey
installed on your machine by running:
choco --version
3. Check if virtualization is supported on your machine by running:
systeminfo
This output means your system already has a virtualization setup.
4. Install kubectl
by running:
choco install kubernetes-cli
5. To verify if kubectl
installed successfully, run:
kubectl version --client
You should see the version of kubectl
that was just installed.
6. Navigate to your user folder by running:
cd %USERPROFILE%
7. Create a new folder .kube
:
mkdir .kube
8. Create a new file config
inside the .kube
folder:
cd .kube
New-Item config -type file
The config
file will be used to tell kubectl
which cluster it should connect to and will be populated automatically.
Step 2— Install minikube
minikube
is a tool that runs a single-node Kubernetes cluster in a virtual machine on your local computer.
- To install using
chocolatey
, run the following command in your command prompt as an administrator:
choco install minikube
2. With minikube
installed, you can then create a Kubernetes cluster using the command:
minikube start --vm-driver=hyperv
where hyperv
is the driver name since Hyper-V is enabled on your machine. Several options listed here can be used as the driver name — it all depends on what you have set up.
If minikube
starts successfully, you should see the following output
With this, you now have a running demo cluster in the setup virtual machine on your local host.
You can verify that everything works by running
minikube status
This should output the status of the minikube
components.
At this point, your Kubernetes cluster is set up locally and you can interact with it using the kubectl
command-line tool.
You can also access a visual dashboard to look into your cluster. To open the dashboard, run:
minikube dashboard
This opens up a new browser tab where you should see the Kubernetes dashboard interface.
And that wraps it up. If you’ve read to this point, congratulations! You can now set up a Kubernetes cluster on your local machine using the Windows operating system.