I Made a Local Kubernetes Startup Script So You Don’t Have To
If you are getting started with Kubernetes development, one of the first things you are going to need is a way to run Kubernetes on your…
If you are getting started with Kubernetes development, one of the first things you are going to need is a way to run Kubernetes on your computer. There are a bunch of different ways to startup Kubernetes locally, but almost all of them either have a bunch of complicated steps or require you to understand Kubernetes in the first place (which kind of defeats the purpose). So to solve that problem for you (and myself, honestly) I wrote a simple Kubernetes startup script that will get you a running local cluster in no time.
What you get with this script
This Kubernetes startup script will install a local cluster on your machine, set up a local container repository, and install the NGINX Kubernetes ingress controller. With these three things, you should be able to install anything you want on the cluster and see it work.
Prerequisites
Before running the script, here are a few things you will need and how to install them
Docker — Install docker desktop from https://www.docker.com/products/docker-desktop/
Homebrew — This script is written for Mac. Check out this article for how to install homebrew
If you are using a mac, this is all you need before running my script. If you are running windows, you will need to install Kubernetes Kind in WSL2
Downloading the script
You can download the local Kubernetes startup script here
How to use the local Kubernetes startup script
After you have downloaded the script, save it somewhere that you can access it easily, or put it in your /usr/local/bin
directory and name the file lk8s
Next, you can run the startup by running lk8s up
If you are successful, it should look like this:
Should now be able to run kubectl get pods
and see that the cluster responds.
Local repository
This script installs the Kind local registry. You can read more about that here. Essentially, this script allows you to push your containers to a local registry instead of Docker hub or other public registries so you can test things out.
Ingress controller
This script installs the NGINX ingress controller Kubernetes automatically. One feature that always seems missing from a local Kubernetes cluster is a way to use Ingress objects properly. This script handles that part for you. Just create an ingress for the localhost domain and you are all set.
Simple up and down
As mentioned above, this local Kubernetes startup script has a super simple command which will save you a ton of time in the long run. Just run lk8s up
and lk8s down
. It’s that simple.