WittCode💻

How to Run Kubernetes Locally

By

Learn how to run Kubernetes locally using Docker. We will also go over the Kubernetes client kubectl and what a Kubernetes context is.

Table of Contents 📖

How to Run Kubernetes Locally

Kubernetes can be ran locally in a variety of ways. One of the simplest ways is to use Docker, spinning up a Dockerized Kubernetes server. We can then interact with this Kubernetes server using the Kubernetes client kubectl.

INFO: The Dockerized Kubernetes server is not configurable and is a single-node cluster.

Installing Docker Desktop

Therefore, to run Kubernetes locally we first need to install Docker. The easiest way to install Docker is by installing Docker Desktop, a GUI that can be installed on Mac, Linux, and Windows. It can be installed at the following URL:

https://docs.docker.com/guides/getting-started/get-docker-desktop/

Docker Desktop includes a standalone Kubernetes server and client. The client being kubectl.

Enabling Kubernetes

After Docker Desktop is installed, we need to enable Kubernetes. This is done by navigating to settings, Kubernetes, checking "Enable Kubernetes", and then clicking "Apply & Restart". This will build the Docker images required to run the Kubernetes server. It also installs the kubectl client.

INFO: kubectl allows us to issue commands against Kubernetes clusters. This includes deploying applications, inspecting clusters, etc.

The install location of the kubectl client is operating system dependent. In any case, make sure that it is placed inside your PATH variable so that it can be accessed anywhere.

Verifying Installation

To verify everything is working, we can run the following command:

kubectl config get-contexts
CURRENT   NAME             CLUSTER          AUTHINFO         NAMESPACE
*         docker-desktop   docker-desktop   docker-desktop

This command retrieves information about all Kubernetes contexts. A context defines how to communicate with a Kubernetes cluster. Specifically, a context is a YAML object stored in a Kubeconfig file. Here we can see the current context is "docker-desktop".