Lan Containers in Kubernetes with Rancher

When running containers that I want available on my LAN, it's handy to expose them under their own LAN IP. To do this I set my DHCP server to stop allocating addresses past .189, and will reserve the remaining IP addresses for container use.

To allocate LAN IP addresses for containers in Kubernetes I use MetalLB. I installed it using kubectl (Rancher makes it easy to download the kube config file).

Then I setup a ConfigMap YAML:

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
      - name: default
        protocol: layer2
        addresses:
        - 192.168.2.190-192.168.2.254

And applied with:

kubectl apply -f metallb_config.yaml

Unifi Controller

I'm changing the IP of where the existing Unifi controller runs, which comes with an interesting drawback. All the existing Unifi devices need to start reporting to the new controller.

First, login to existing controller, and download a full backup. Then setup the new controller, my unifi-controller.yaml looks like this:

I created a namespace for unifi in the Rancher UI, where I'll run my Unifi containers.

To spin up the container on its new IP:

kubectl -n unifi apply -f unifi-controller.yaml

This can take a few minutes to come-up, it has to play with ARP responses and such. Once the new Unifi controller was up, I restored the backup and logged in. None of the devices will show up.… yet!

On the old Unifi controller, I went to Settings -> Site and clicked the Export Site button. You can download a backup file here, but the more important step is to migrate the devices to the new controller by providing the new IP for them to inform. Once this step is done, the devices should show up in the new controller shortly.

The old controller can then be shutdown.

Unifi Video Controller

I used this kubernetes file to setup my unifi video controller:

I'm using the /mnt/data directory that is the second SATA SSD drive for these containers to store their data on.

After restoring this from the backup I made of my old unifi video controller, I logged in, selected the camera, and under Manage I changed its reporting IP to the new container IP.

Ben Bangert
Ben Bangert
Software Contriver

Code. Homebrew. Hike. Rollerblade.