Traefik and Metallb External IPs Stuck Pending in K3s Cluster Deployment on Ubuntu
In this article, we will cover the topic of deploying a K3s cluster locally on Ubuntu, with Traefik and Metallb as the load balancer and ingress controller. We will discuss the issue of external IPs getting stuck in a pending state, and provide solutions to resolve this problem.
Introduction
K3s is a lightweight Kubernetes distribution that is ideal for running on resource-constrained devices such as IoT devices, edge devices, and development machines. Traefik is a popular load balancer and ingress controller for Kubernetes, while Metallb is a layer 2 load balancer for Kubernetes.
Prerequisites
Before we begin, make sure you have the following:
- A local Ubuntu machine with at least 2GB of RAM and 20GB of free disk space
- K3s installed on the Ubuntu machine
- Helm installed on the Ubuntu machine
Deploying Traefik and Metallb
To deploy Traefik and Metallb, we will use Helm charts. First, we need to add the Helm repositories for Traefik and Metallb:
helm repo add traefik https://helm.traefik.io/traefik
helm repo add metallb https://metallb.github.io/metallb
Next, we will create a namespace for Traefik and Metallb:
kubectl create namespace traefik
Now, we can deploy Traefik and Metallb using Helm:
helm install traefik traefik/traefik --namespace traefik \
--set kubernetes.ingressClass=traefik \
--set service.type=LoadBalancer \
--set service.externalTrafficPolicy=Local \
--set service.annotations."service\.beta\.kubernetes\.io/aws-load-balancer-type"=nlb \
--set service.annotations."service\.beta\.kubernetes\.io/aws-load-balancer-nlb-target-type"=ip \
--set service.annotations."service\.beta\.kubernetes\.io/aws-load-balancer-scheme"=internet-facing \
--set service.annotations."service\.beta\.kubernetes\.io/aws-load-balancer-subnets"=subnet-0123456789abcdef0
helm install metallb metallb/metallb --namespace traefik \
--set configInline.addressPools[0].name=default \
--set configInline.addressPools[0].protocol=layer2 \
--set configInline.addressPools[0].autoAssign=true
Note: Replace the subnet-0123456789abcdef0 with the actual subnet ID of your VPC.
Issue: External IPs Stuck Pending
After deploying Traefik and Metallb, you may notice that the external IPs for the Traefik service are stuck in a pending state:
kubectl get svc -n traefik
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
traefik LoadBalancer 10.43.18.137 <pending> 80:31427/TCP,443:32688/TCP 10m
This issue occurs because Metallb is waiting for the IP addresses to be assigned by the cloud provider. However, since we are running this cluster locally, there is no cloud provider to assign the IP addresses.
Solution: Assigning IP Addresses Manually
To resolve this issue, we need to assign the IP addresses manually. We can do this by creating a ConfigMap for Metallb:
cat <<EOF
apiVersion: v1
data:
address-pools: |
- name: default
protocol: layer2
addresses:
- 192.168.1.200/32
- 192.168.1.201/32
EOF
kubectl create configmap -n traefik metallb-config --from-file=-
Replace the IP addresses with the actual IP addresses you want to use. Make sure these IP addresses are not in use by any other devices on your network.
After creating the ConfigMap, the external IPs for the Traefik service should be assigned:
kubectl get svc -n traefik
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
traefik LoadBalancer 10.43.18.137 192.168.1.200,192.168.1.201 80:31427/TCP,443:32688/TCP 15m
In this article, we discussed the issue of external IPs getting stuck in a pending state when deploying Traefik and Metallb on a K3s cluster locally on Ubuntu. We provided a solution to assign the IP addresses manually using a ConfigMap for Metallb. With this solution, you should be able to deploy Traefik and Metallb on a K3s cluster locally on Ubuntu without any issues.