Debian 12 - Set Up Nginx Load Balancer For K3s
The tutorial below is how I set up my load balancer on Debian 12 for Kubernetes.
Resource Requirements
I would recommend at least:
- 2 vCPUs
- 512 MB of RAM
Steps
Install Nginx
sudo apt update && sudo apt install nginx-full -y
nginx-full
package instead of just nginx
.
Otherwise you will have an issue with starting the nginx server later due to the use of the stream directive.
Now replace your Nginx configuration using the command below. Be sure to change the IP addresses of the k3s_servers
block as appropriate for your Kubernetes API servers.
sudo echo "user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {}
stream {
upstream k3s_servers {
server 192.168.0.68:6443;
server 192.168.0.69:6443;
server 192.168.0.70:6443;
}
server {
listen 6443;
proxy_pass k3s_Servers;
}
}" | sudo tee /etc/nginx/nginx.conf
Reload Nginx:
sudo nginx -s reload
References
Last updated: 15th January 2025
First published: 13th January 2025
First published: 13th January 2025