DEV Community

Chillar Anand
Chillar Anand

Posted on • Originally published at avilpage.com on

Setup Kubernetes Anywhere with Single Command

Introduction

In an earlier article, we have seen how to set up Kubernetes on M1 Mac. That involved spinning up a VM and installing Kubernetes1 on it. In this article, we will see how to set up Kubernetes directly on Docker so that we can use the same set-up on any operating system.

Prerequisites

Ensure you have Docker installed on your system. If you are on a Mac or Windows, you can install Docker Desktop2.

k3s/k3d

k3s3 is a lightweight Kubernetes distribution by Rancher. It is a single binary that can be run on any Linux machine. But it doesn't work on Mac or Windows.

k3d4 is a wrapper around k3s that allows you to run k3s on Docker. It is a great option for running Kubernetes on your local machine.

Installation

k3d can be installed using the following command:

$ brew install k3d # mac
$ chocolatey install k3d # windows
$ curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash # linux

Enter fullscreen mode Exit fullscreen mode

Once it is installed, we can create a cluster using the following command:

$ k3d cluster create demo

Enter fullscreen mode Exit fullscreen mode

This will launch a cluster with a single node. We can verify the cluster is up and running using the following command:

$ kubectl get nodes

Enter fullscreen mode Exit fullscreen mode

We can also use GUI tools like Lens to manage and navigate the cluster. In the above video we have used Lens to create a Jenkins deployment as well.

Conclusion

In this article, we have seen how to set up Kubernetes on Docker. This is a great option for running Kubernetes on your local machine. We can also use this to run production setup for small applications.


  1. https://kubernetes.io/

  2. https://www.docker.com/products/docker-desktop/

  3. https://k3s.io/

  4. https://k3d.io/

Top comments (0)