/local-k8s

A short way to get a local kubernetes development cluster up and running on a local machine with Docker Desktop and expose apps to the internet for testing purposes.

Primary LanguageShell

local development cluster

This is work in progress

A short way to get a local kubernetes development cluster up and running on a local machine with Docker Desktop and expose apps to the internet for testing purposes.

Do not clone this repo now. We do this later in the devbox container.

Architecture

architecture

Prerequisites

Activate Kubernetes on Docker Desktop:

-> Docker Desktop -> Preferences -> Kubernetes -> Enable Kubernetes

Start the devbox container

Linux/MacOS:

docker run -d --hostname devbox -p 2080:2080 --rm \
  -v devboxhome:/home/coder \
  -v ${HOME}/.kube/config:/home/coder/.kube/config \
  --name local-k8s-devbox \
  isi006/code-server-k8s:latest

Windows:

docker run -d --hostname devbox -p 2080:2080 --rm -v devboxhome:/home/coder -v %userprofile%/.kube/config:/home/coder/.kube/config --name local-k8s-devbox isi006/code-server-k8s:latest

Visit http://localhost:2080/ to access the devbox IDE.

Open a terminal and check if it works:

kubectl cluster-info

Clone the repo in the devbox

git clone https://github.com/klauserber/local-k8s.git

Minimal infrastructure setup

configure

cp config.yml_template config.yml

Edit the config file to choose your domain suffix to build unique localtunnel subdomains.

install ingress-nginx

-> https://artifacthub.io/packages/helm/ingress-nginx/ingress-nginx

cd ingress-nginx
./run.sh

check if it works:

kubectl get all -n ingress-nginx

Test the system with the hello-app

Deploy the app

cd hello-app
./run.sh

Testing

kubectl get all -n hello-app

Visit http://hello.127.0.0.1.nip.io for local access.
Visit https://hello{{public_domain_suffix}} for public access.

Undeploy the app

./run.sh -d

Optional: Deploy portainer

You can install Portainer to get more insights about the cluster.

cd portainer
./run.sh

Visit the app at http://portainer.127.0.0.1.nip.io

Next steps?

This is a good starting point to play around with kubernetes on your local machine. So what can you do next?