In this post, I’ll walk you through the steps I took to set up my RKE2 Kubernetes cluster, configure MetalLB as a load balancer, utilize the Nginx Ingress Controller to route traffic to multiple services, such as Grafana and Nginx, and manage persistent storage using Persistent Volumes (PVs) and Persistent Volume Claims (PVCs).
This was done in a test environment with:
- 1 Master node
- 2 Worker nodes
- Your Custom domain: sanjaymaharjann.com.np
- Services exposed via Ingress resource:
- Grafana → grafana.sanjaymaharjann.com.np
- Harbor (or NGINX test pod) → harbor.sanjaymaharjann.com.np or nginx.sanjaymaharjann.com.np
- MetalLB: Assign an IP address to the services of type loadbalancer.
Let’s dive in!
Prerequisites: Before we begin, ensure you have the following ready:
- RKE2 Cluster [One master, two worker nodes]
- kubectl [Configured to access your cluster]
- Domain [A custom domain like sanjaymaharjann.com.np]
- TLS Certificate [Wildcard cert (*.sanjaymaharjann.com.np)]
- DNS Provider [To point subdomains to Ingress IP or, in my case, localhost DNS resolver.]
- MetalLB [For LoadBalancer support and a subnet of your custom network.]
*Step 1: Install RKE2 Cluster *
I started by installing RKE2 using Rancher's official documentation[https://docs.rke2.io/install/methods].
After setting up the control plane and joining the worker nodes, I verified everything was running:
root@master:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
agent1 Ready <none> 20d v1.31.8+rke2r1
agent2 Ready <none> 20d v1.31.8+rke2r1
master Ready control-plane,etcd,master 20d v1.31.8+rke2r1
root@master:~# hostname
master
root@master:~#
✅ All nodes are up and healthy.
*Step 2: Installation of MetalLB *
Since this is a bare-metal setup, I used MetalLB as my LoadBalancer provider.
kubectl create namespace metallb-system
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.10/config/manifests/metallb-native.yaml
root@master:~# kubectl get pods -n metallb-system
NAME READY STATUS RESTARTS AGE
controller-5456bd6d98-vwd6j 1/1 Running 0 15d
speaker-429lj 1/1 Running 0 15d
speaker-7pzgf 1/1 Running 0 15d
speaker-ww8r2 1/1 Running 0 15d
Create a config file for the metallb configuration to advertise the IP pool. Simply, create a file metallb-config.yaml and paste the contents as:
# metallb-config.yaml
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: my-ip-pool
namespace: metallb-system
spec:
addresses:
- 10.0.2.240-10.0.2.250
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: l2adv
namespace: metallb-system
spec:
ipAddressPools:
- my-ip-pool
Apply it with:
kubectl apply -f metallb-config.yaml
root@master:~/metallb# kubectl get pods -n metallb-system -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
controller-5456bd6d98-vwd6j 1/1 Running 0 15d 10.42.1.35 agent1 <none> <none>
speaker-429lj 1/1 Running 0 15d 10.0.2.109 master <none> <none>
speaker-7pzgf 1/1 Running 0 15d 10.0.2.112 agent2 <none> <none>
speaker-ww8r2 1/1 Running 0 15d 10.0.2.111 agent1 <none> <none>
root@master:~/metallb# kubectl get l2advertisement -n metallb-system
NAME IPADDRESSPOOLS IPADDRESSPOOL SELECTORS INTERFACES
l2adv ["my-ip-pool"]
root@master:~/metallb# kubectl get ipaddresspool -n metallb-system
NAME AUTO ASSIGN AVOID BUGGY IPS ADDRESSES
my-ip-pool true false ["10.0.2.240-10.0.2.250"]
Top comments (0)