Kubernetes Self Hosted Home Lab

Kubernetes Self Hosted Home Lab

This post covers how to install Docker & Kubernetes on Windows 10 Pro/Ent using Hyper-V/PowerShell/Chocolatey. Ensure Hyper-V features are enabled before proceeding. All commands are run via PS.

— Docker Setup —

Install Chocolatey:
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Install Docker for Windows using:
choco install docker-desktop -y

Reboot your Windows host to complete the installation.Upon reboot, check that a Hyper-V VM with the name MobyLinuxVM is up and running.

Spin up an nginx docker container using:
docker run -ti -p 8080:80 nginx

Visit http://localhost:8080 and you should see the nginx start page.
Congrats, you've installed Docker successfully. This is an independent install of Docker. It won't talk to minikube at all, but it's a good toolset for spinning up and playing around with containers. We'll install minikube next, it hosts it's own Docker daemon within the VM itself.

— Kubernetes Setup —

Install minikube using:
choco install minikube -y

Configure minikube use an existing Hyper-V Virtual Switch via PowerShell:
minikube start --vm-driver=hyperv --hyperv-virtual-switch=NAME

To create one for use with minikube (Adapter with External Access on Host):

New-VMSwitch –Name "minikube" –AllowManagement $True –NetAdapterName "INSERT_HERE_ADAPTER"

Boot and configure minikube to use your switch:
minikube start --vm-driver=hyperv --hyperv-virtual-switch=NAME

If this fails to boot you can use: minikube delete.

Make sure your minikube node is up and running:
kubectl get nodes

Open your minikube dashboard:
minikube dashboard

— Deploy your first pod in Kubernetes —

Deploy using kubectl:
kubectl run hello-nginx --image=nginx --port 80

Check the status of the deploy:
kubectl get pods

Expose to hit the pod:
kubectl expose deployment hello-nginx --type=nodeport

get the URL for nginx:
minikube service --url=true hello-nginx

Open nginx via browser:
minikube service hello-nginx

— Scale Test —

Create a replica of your existing pod:
kubectl scale --replicas=2 deployment/hello-nginx

Check that your replicas are up and running:
kubectl get deployment