It’s an abbreviation for Reverse Proxy Load Balancer - not very creative, I know. In this blog post I’ll explain why it exists and how to use it.
Read more and get the project on GitHub.
Motivation
As with all software, even a little project like this needed a reason to be created. As I already mentioned in few older articles, I’m learning Go and I was looking for a real project to work on.
And for work related reasons, I’m also learning a bit of Kubernetes, but mostly ArgoCD and some other things. To do that, I set up a three-node bare metal Microk8s cluster running in High Availability.
I wanted to access ArgoCD by going to http://argocd.example.com
and to be able to hit one of the available nodes. All the reverse proxy and load balancing solutions I found had, in my opinion, too complicated configuration and a steap learning curve. This is essentially how this project started.
How to use it
I already had a few things in my networking setup that enabled this to work:
- Home Assistant running AdGuard Home
- Router pointing to Home Assistant for DNS resolution
- Home Assistant running on a Raspberry Pi that can also run applications in docker
So, let’s imagine the following scenario:
Router on
192.168.0.1
Home Assistant on
192.168.0.2
Three kubernetes nodes on
192.168.0.3
,192.168.0.4
and192.168.0.5
myapp service exposed on
:1234
on those nodes
And I want http://myapp.example.com:8080
to hit that service in round-robin
fashion.
At this point all I have to do is pull and run the latest RPLB image, and configure a AdGuard Home DNS rewrite.
To run docker commands on Home Assistant I needed to install SSH & Web Terminal Community Add-on and then run:
1 | docker pull ghcr.io/dalibormesaric/rplb:latest |
In AdGuard Home I had to add a DNS rewrite like so:
This will tell your router that myapp.example.com
is hosted on 192.168.0.2
, which is Home Assistant. Port :8080
will be picked up by RPLB running in docker.
RPLB then checks the hostname of incoming requests and based on initial configuration finds the backend to which it forwards the requests to. RPLB is also constantly monitoring the availability of all backends to make sure that the request is send only to one of the healthy backends.
Of course, I would really like to get rid of :8080
, but ports 80 and 443 are taken by NGINX Home Assistant SSL proxy in my setup and I didn’t have time to change that.
As a bonus, there is a dashboard available on http://myapp.example.com:8000
where you can Monitor
health of your backends and see the Traffic
being routed according to the configured load balancing algorithm.
There is also http://myapp.example.com:8000/metrics
endpoint so you can scrape it with tools like Prometheus and build your own dashboards.
Conclusion
At this point I’ve been using RPLB for some time and it’s in a good enough state that I can blog about it. Over time I plan to make some small changes and improve documentation. This was a really interesting exercise in building an application in Go and I look forward to doing more in the future!