Objective: Configure network on K3s
MetalLB
MetalLB is a Kubernetes-based load balancer that assigns IP addresses to services, facilitating network requests to those IPs.
Install MetalLB on main control node
# Add MetalLB repository to Helm
helm repo add metallb metallb.github.io/metallb
Check the added repository
helm search repo metallb
Install MetalLB
helm upgrade –install metallb metallb/metallb –create-namespace \ –namespace metallb-system –wait
Now that MetalLB is installed, we need to assign an IP range for it. In this case, we allow MetalLB to use the range 10.0.20.170 to 10.0.20.180.
cat << 'EOF' | kubectl apply -f -
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: default-pool
namespace: metallb-system
spec:
addresses:
- 10.0.20.170-10.0.20.180
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: default
namespace: metallb-system
spec:
ipAddressPools:
- default-pool
EOF
Traefik
Traefik is an open-source reverse proxy and load balancer used extensively in Kubernetes environments. Traefik is pre-installed with K3s.
However, to utilize Traefik, a working DNS server external to the Kubernetes cluster is required. For local testing, the /etc/hosts file can be modified to act as a faux DNS server.
Edit /private/etc/hosts
10.0.20.170 turing-cluster turing-cluster.local
Now, when we enter https://turing-cluster.local in the browser, we are redirected to a 404 page of Traefik.
Later, I will add this info to my DNS server. For now, my testing works.
Next up… storage.