MetalLB on k3s

Do repost and rate:

MetalLB is a simpler piece to install on our cluster, but it provides the ability to acquire additional IP addresses within your LAN. This is useful if you want to deploy things to the mDNS .local domain name on your LAN (home network).  This post will cover installing MetalLB in layer 2 mode, and detailing how to add a *.local domain name in your home network - this will only be accessible when you are connected to your router.

Installation

MetalLB can be installed with 3 simple commands:

kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.6/manifests/namespace.yamlkubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.6/manifests/metallb.yaml# On first install onlykubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"

If you get stuck though, or these commands don't work for you, be sure to check out the full installation docs.

Configuring

After MetalLB is installed, you must provide a config map named config in the metallb-system namespace.

---apiVersion: v1kind: ConfigMapmetadata:  namespace: metallb-system  name: configdata:  config: |    address-pools:    - name: default      protocol: layer2      addresses:      - 192.168.2.1-192.168.2.254

This config map tells MetalLB to run in layer 2, and gives it permission to bind to any ip address 192.168.2.1-254 - you'll need to go to your router configuration though and check and see for yourself what IPs your router currently works with.

Additionally, I needed to update my subnet mask so that devices that connect to my router via DHCP (regular WI-FI connections) could access IP addresses on this other subnet.

My DHCP server assigns addresses in the 192.168.1.xxx range, and so for those IPs to be allowed to communicate with the 192.168.2.xxx range of IP addresses, I needed to make my subnet mask 255.255.252.0.  If you are looking for something different, I strongly recommend an IP Subnet Calculator.

If you don't correctly configure your router subnets, you will not be able to access these additional IP addresses from devices on a different network subnet in your home. This part of my home server taught me just how complicated networking is!

mDNS Support

After you have MetalLB installed, you have the ability to manually add mDNS (multicast DNS) names to your home network. These days, most routers support mDNS, and so we'll configure the default mDNS utility for Linux - avahi - to act as an mDNS responder for some of these IP addresses that are controlled by MetalLB.

On your Kubernetes master, go ahead and ensure Avahi is installed

sudo apt update \&& sudo apt install avahi-daemon

This will also start Avahi.  Now, to add a new *.local domain name, edit /etc/avahi/hosts on this server.

### Provide mDNS for traefik - ip address owned by MetalLB192.168.2.77 traefik.local

If we've configured Traefik to have the 192.168.2.77 Load Balancer IP address, this will make http://traefik.local accessible on our LAN after we save this entry.  Entries in this file follow your typical /etc/hosts format of IP address and domain name, space separated.  I do not think this will work for things other than .local domain names, but you are welcome to try. 

As a reminder, this post is part of the k3s install parent post, and the next post in this mega series is installing Longhorn - you'll need a storage provider to be able to save SSL certificates that are generated via LetsEncrypt. If you are using a different storage provider, feel free to jump to the last post in this mega series is installing Traefik (v2).

 

Regulation and Society adoption

Events&meetings

Ждем новостей

Нет новых страниц

Следующая новость