Own your networking, metallb
Before getting to the main point of this article, let me say something: you should check our previous post where Frank explains how to enable gitops in k8s. We love helm-controller and in this article you will learn why.
Kubernetes, the basics
If you played with Kubernetes before, you already know what a service is –if not, this guide is for you– and if you don’t know what an ingress is.. this guide is for you.
Veni, Vidi, Vici. Networking
Kubernetes is taking control of everything and, like Cesar, with each domain it arrives at, it sees how to enter and then conquers. K8S allows for a lot of approaches to attack networking, and everything seems to be solved through different layers, but what if you want to manage your own IP addresses?
MetalLB provides Kubernetes services like LoadBalancer, with two useful features: Address Allocation and External Announcement.
Address Allocation
MetalLB assigns individual addresses to services from a given pool of addresses, as long as you own it.
External Announcement
Using standard routing protocols, MetalLB announces to the network where the IP lives, which lets your Kubernetes cluster balance the IP using a layer 2 mode (ARP/NDP) and even using a BGP mode.
Installation
Installing Metallb is just as simple as having a Kubernetes cluster (version 1.13.0 or later), without a load-balancing functionality. If you love k3s like we do, you can install k3s with the following sentence:
After that, apply the manifest:
This will deploy components that will remain idle until you add a configmap which will feed the cluster with the pool you want to manage. In a Layer 2 mode, the configuration could be something as simple as:
For advanced config, take a look at the excellent documentation that this project has.
Finally, if you checked our previous article and would like to deploy an example app you only need to define a service.loadBalancerIP entry:
After applying it, you will be able to point your browser to the IP. You can also check the logs of the metallb’s controller and speaker, to find interesting information on how it works.
Clap our article and let us know if it worked for you!