Building the home lab Kubernetes playground – Part 7
Tags: kubernetes, cloudnative, containerlearning, kasten
Published: 2021-03-06 09:51:47

---
title: Building the home lab Kubernetes playground – Part 7
published: true
date: 2021-03-05 21:57:05 UTC
tags: Kubernetes,CloudNative,containerlearning,kasten
canonical_url: https://vzilla.co.uk/vzilla-blog/building-the-home-lab-kubernetes-playground-part-7
---

In the last post we talked about context and how you can flip between different cluster control contexts from your Windows machine. We have also spoken about in this series how load balancing gives us a better access to our application vs using the node port for access.

This post will highlight how simple it is to deploy your load balancer and configure for your home lab Kubernetes cluster.

# Roll your own Load Balancer

If you deployed your Kubernetes cluster in Cloud, the cloud provider will take care of creating Load balancer instances. But if you are using bare metal for Kubernetes cluster, you have very limited choices which is where we are in this home lab scenario this also enables for us to have choice and to understand why. As I mentioned this is going to be using MetalLB.

Let’s start by what it looks like without a load balancer on bare metal when we are limited to Node or Cluster port configurations. So I am going to create a nginx pod.

![](https://vzilla.co.uk/wp-content/uploads/2021/03/030521_2153_Buildingthe1.png)

If we did not have a load balancer configured but we used the following command here. It would stay in the pending state until we did have a load balancer.

kubectl expose deploy nginx –port 80 –type LoadBalancer

## Installing MetalLB

To start you can find the installation instructions [here](https://metallb.universe.tf/installation/). The following commands in general is going to deploy MetalLB to your cluster, it will create a namespace called metallb-system and it will create a controller which is what will control IP address assignments and then also speaker which handles the protocols you wish to use.

kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.5/manifests/namespace.yaml

kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.5/manifests/metallb.yaml

# On first install only

kubectl create secret generic -n metallb-system memberlist –from-literal=secretkey=”$(openssl rand -base64 128)”

when you have than these you should see the new namespace metallb-system and be able to run the following command

kubectl get all -n metallb-system

![](https://vzilla.co.uk/wp-content/uploads/2021/03/030521_2153_Buildingthe2.png)

We then need a config map to make it do something, or at least use specific IP addresses on our network, I am using Layer2 in my lab configuration but there are other options that you can find [here](https://metallb.universe.tf/configuration/).

![](https://vzilla.co.uk/wp-content/uploads/2021/03/030521_2153_Buildingthe3.png)

Create your YAML if layer2 as above with a range of IP addresses available on your home lab network and then apply this into your configuration. Where config.yaml is the YAML file with your config as per above is located.

kubectl apply -f config.yaml

now when you deploy a service that requires port type as LoadBalancer

kubectl expose deploy nginx –port 80 –type LoadBalancer

Instead of pending now this will give you an IP address available on your home lab network, which is great then if you want to access this from outside your cluster. Now if we check another application I have running already in my cluster. You will see the following when you use the LoadBalancer type on deployment.

![](https://vzilla.co.uk/wp-content/uploads/2021/03/030521_2153_Buildingthe4.png)

And then if we go into that service and describe we can then see that configuration

![](https://vzilla.co.uk/wp-content/uploads/2021/03/030521_2153_Buildingthe5.png)

I want to give another shout out to [just me and opensource](https://www.youtube.com/watch?v=xYiYIjlAgHY) if you are a consumer of video vs written or both then this guy has created an amazing Kubernetes playlist covering all things Kubernetes and more.

In the next post we are going to focus on hitting the easy button for our apps using KubeApps, where things do not need to be all in the shell there are also UI options, KubeApps is the “Your Application Dashboard for Kubernetes”

The post [Building the home lab Kubernetes playground – Part 7](https://vzilla.co.uk/vzilla-blog/building-the-home-lab-kubernetes-playground-part-7) first appeared on [vZilla](https://vzilla.co.uk).