Setting Up K3S in High Availability
Prerequisites Hardware
Item | Description |
|---|---|
4GB or 8GB | |
7.4-17 |
Between Raspberry Pi's and proxmox, create Four instances of Ubuntu 23.04.1 LTS.
Configure a SQL Server
sudo apt install mysql-server
sudo systemctl start mysql.service
Replace 10.0.0.0 with the home network address range.
Create a user for K3s on the SQL Database
CREATE DATABASE homelab;
CREATE USER 'k8s' IDENTIFIED BY 'password'
GRANT ALL PRIVILEGES ON *.* TO 'k8s'@'10.0.0.0/255.255.255.0';
Install K3S Running as Master on Two Nodes
For each master node, run the following
curl -sfL https://get.k3s.io | sh -s - server --datastore-endpoint="mysql://k8s:k8s_password@tcp(SQL_DB_IP:3306)/homelab"
Configure Nginx to load balance between the two instances.
Install Nginx
sudo apt install nginxUpdate the file
/etc/nginx/nginx.confto the following
stream {
server {
listen 6443;
proxy_pass stream_master_nodes;
}
upstream stream_master_nodes {
server IP_of_Node_1:6443;
server IP_of_Node_2:6443;
}
}
Install K3S Running as Worker on Two Nodes
For each worker node, run the following
curl -sfL https://get.k3s.io | sh -s - agent --server http://IP_of_Nginx_Load_Balancer:6443
Last modified: 10 November 2023