You run a bare-metal Kubernetes cluster. Your workloads need an HTTP ingress IP, you don’t have a cloud load balancer to lean on, and the cheap answer — exposing a NodePort and pointing DNS at one node — has the obvious problem that the node dies and you find out. People reach for ingress-nginx and forget that it needs a stable IP in front of it. People reach for MetalLB and forget that on its own it just hands out IPs; it doesn’t terminate traffic. The combination is what you actually want — MetalLB advertises a virtual IP that fails over between nodes, ingress-nginx runs as a DaemonSet so every node has an ingress controller pod, and the LB IP is wired to whichever node MetalLB elects as the announcer.
What’s happening
A bare-metal cluster is missing the cloud-provider load balancer. When a Service of type LoadBalancer comes up, nothing assigns it an external IP. You can paper over this with externalIPs on the Service or with hostPort on a DaemonSet — both work, both have failure modes. MetalLB fills the gap by speaking either L2 (gratuitous ARP, one node “owns” the IP at a time, traffic redirects on failure of the elected node in 5-10 seconds) or BGP (every node advertises the IP to a router, ECMP load-balances per-flow). L2 is simpler and what most teams pick; BGP is correct when you have a routed fabric and want symmetric ingress, and even then MetalLB BGP is best replaced by the BGP support in Cilium or Calico once you’re at that scale. This installer covers L2 because it works in any environment where the cluster nodes share a broadcast domain — which is most bare-metal setups outside of a routed colo. ingress-nginx runs as a DaemonSet so there’s a controller pod on every node, the Service externalTrafficPolicy: Local preserves client IPs (no SNAT), and MetalLB advertises one IP that the upstream firewall can target. Two failures and you’re still up; the failover happens at the MetalLB layer, not at DNS.
How to verify
Confirm the cluster has no built-in load balancer:
kubectl get svc -A | awk '$5=="<pending>"'
# Any Service stuck in <pending> means no LB controller is reconciling it.
Check that the nodes are in the same L2 segment (required for MetalLB L2 mode):
# From any node, ping each other node by hostname / IP
# All should be sub-millisecond and not traverse a router
ip -4 addr show
ip route show
Identify a free IP range on the node subnet. Look at the existing assignments and pick a block nothing else uses:
nmap -sn 10.10.0.0/24 | head -50 # or arp-scan, or your DCIM
Confirm kube-proxy strict-arp is on (MetalLB L2 requires it):
kubectl get configmap -n kube-system kube-proxy -o yaml | grep strictARP
# strictARP: true
If strictARP: false or absent, the installer below sets it.
The fix
Save as /root/install-ingress-metallb.sh and run from one control-plane node. The script enables strictARP in kube-proxy, installs MetalLB 0.14 via its manifest (the operator path is also fine; this article uses the manifest install for simplicity), configures an IPAddressPool and L2Advertisement, installs ingress-nginx 1.11 with a DaemonSet deployment and externalTrafficPolicy: Local, and runs end-to-end verification with a sample workload.
#!/usr/bin/env bash
set -euo pipefail
### MetalLB 0.14 (L2 mode) + ingress-nginx 1.11 HA installer for bare-metal Kubernetes
### Run from any control-plane node
### Assumes nodes share a broadcast domain
if [[ "$(id -u)" -ne 0 ]]; then
echo "Run as root."
exit 1
fi
if ! command -v kubectl >/dev/null; then
echo "kubectl not found — run on a control-plane node."
exit 1
fi
# === EDIT BEFORE RUNNING ===
METALLB_VERSION="v0.14.8"
INGRESS_NGINX_VERSION="v1.11.3"
LB_IP_POOL="10.10.0.240-10.10.0.250" # free range on the node subnet
INGRESS_LB_IP="10.10.0.240" # specific IP for ingress-nginx
HUB_DOMAIN="ingress.internal.example" # test hostname for smoke test
# ===========================
echo "==> Verifying cluster reachable"
kubectl cluster-info
echo "==> Enabling strictARP on kube-proxy (required for MetalLB L2)"
kubectl get configmap -n kube-system kube-proxy -o yaml \
| sed -E 's/(strictARP:) (true|false)/\1 true/' \
| sed -E '/mode: "ipvs"/!s/(mode: ).*/\1"iptables"/' \
> /tmp/kube-proxy.yaml
# Insert strictARP: true if absent
if ! grep -q strictARP /tmp/kube-proxy.yaml; then
sed -i '/^data:/a\ config.conf: |\n apiVersion: kubeproxy.config.k8s.io/v1alpha1\n kind: KubeProxyConfiguration\n ipvs:\n strictARP: true' /tmp/kube-proxy.yaml
# The above is fragile — prefer editing the existing config.conf with yq/jq.
# For a clean cluster, the safer path is the kubectl patch below.
fi
kubectl -n kube-system patch configmap kube-proxy \
--type merge -p '{"data":{"_strictarp_marker":"true"}}' >/dev/null
# Actually patch ipvs.strictARP correctly:
kubectl -n kube-system get configmap kube-proxy -o jsonpath='{.data.config\.conf}' \
| sed 's/strictARP: false/strictARP: true/' > /tmp/kp-config.conf
kubectl -n kube-system create configmap kube-proxy \
--from-file=config.conf=/tmp/kp-config.conf \
--from-literal=kubeconfig.conf="$(kubectl -n kube-system get configmap kube-proxy -o jsonpath='{.data.kubeconfig\.conf}')" \
--dry-run=client -o yaml | kubectl apply -f -
kubectl -n kube-system rollout restart daemonset kube-proxy
kubectl -n kube-system rollout status daemonset kube-proxy --timeout=120s
echo "==> Installing MetalLB ${METALLB_VERSION}"
kubectl apply -f "https://raw.githubusercontent.com/metallb/metallb/${METALLB_VERSION}/config/manifests/metallb-native.yaml"
echo "==> Waiting for MetalLB controller + speakers to be ready"
kubectl -n metallb-system wait --for=condition=available deploy/controller --timeout=120s
kubectl -n metallb-system rollout status ds/speaker --timeout=120s
echo "==> Configuring MetalLB IP pool + L2 advertisement"
cat <<EOF | kubectl apply -f -
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: bare-metal-pool
namespace: metallb-system
spec:
addresses:
- ${LB_IP_POOL}
autoAssign: true
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: bare-metal-l2
namespace: metallb-system
spec:
ipAddressPools:
- bare-metal-pool
EOF
echo "==> Installing ingress-nginx ${INGRESS_NGINX_VERSION} as DaemonSet"
kubectl create ns ingress-nginx --dry-run=client -o yaml | kubectl apply -f -
kubectl label ns ingress-nginx app.kubernetes.io/name=ingress-nginx --overwrite
# Apply the bare-metal manifest (DaemonSet, hostNetwork: false, NodePort), then
# patch the Service to LoadBalancer so MetalLB assigns an IP.
kubectl apply -f "https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-${INGRESS_NGINX_VERSION}/deploy/static/provider/baremetal/deploy.yaml"
echo "==> Converting ingress-nginx controller Deployment to DaemonSet (HA per-node)"
kubectl -n ingress-nginx scale deployment ingress-nginx-controller --replicas=0 || true
kubectl -n ingress-nginx delete deployment ingress-nginx-controller --ignore-not-found
cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: ingress-nginx-controller
namespace: ingress-nginx
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
spec:
selector:
matchLabels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
template:
metadata:
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
spec:
serviceAccountName: ingress-nginx
terminationGracePeriodSeconds: 300
nodeSelector:
kubernetes.io/os: linux
tolerations:
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
containers:
- name: controller
image: registry.k8s.io/ingress-nginx/controller:${INGRESS_NGINX_VERSION}
args:
- /nginx-ingress-controller
- --publish-service=ingress-nginx/ingress-nginx-controller
- --election-id=ingress-nginx-leader
- --controller-class=k8s.io/ingress-nginx
- --ingress-class=nginx
- --configmap=ingress-nginx/ingress-nginx-controller
- --validating-webhook=:8443
- --validating-webhook-certificate=/usr/local/certificates/cert
- --validating-webhook-key=/usr/local/certificates/key
securityContext:
allowPrivilegeEscalation: true
capabilities:
add: [NET_BIND_SERVICE]
drop: [ALL]
runAsUser: 101
seccompProfile: { type: RuntimeDefault }
ports:
- name: http
containerPort: 80
protocol: TCP
- name: https
containerPort: 443
protocol: TCP
- name: webhook
containerPort: 8443
protocol: TCP
livenessProbe:
httpGet: { path: /healthz, port: 10254 }
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 5
readinessProbe:
httpGet: { path: /healthz, port: 10254 }
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
resources:
requests: { cpu: 100m, memory: 90Mi }
volumeMounts:
- name: webhook-cert
mountPath: /usr/local/certificates/
readOnly: true
volumes:
- name: webhook-cert
secret:
secretName: ingress-nginx-admission
EOF
echo "==> Patching ingress-nginx Service to LoadBalancer with pinned IP"
kubectl -n ingress-nginx patch svc ingress-nginx-controller \
--type merge -p "{
\"spec\": {
\"type\": \"LoadBalancer\",
\"loadBalancerIP\": \"${INGRESS_LB_IP}\",
\"externalTrafficPolicy\": \"Local\"
},
\"metadata\": {
\"annotations\": {
\"metallb.universe.tf/loadBalancerIPs\": \"${INGRESS_LB_IP}\"
}
}
}"
echo "==> Waiting for DaemonSet to be rolled out"
kubectl -n ingress-nginx rollout status daemonset ingress-nginx-controller --timeout=180s
echo "==> Waiting for LoadBalancer IP assignment"
for i in {1..30}; do
IP=$(kubectl -n ingress-nginx get svc ingress-nginx-controller \
-o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null || true)
if [[ -n "$IP" ]]; then
echo " LoadBalancer IP: $IP"
break
fi
sleep 3
done
echo "==> Smoke test: deploying nginx + Ingress"
kubectl create ns ingress-smoke --dry-run=client -o yaml | kubectl apply -f -
kubectl -n ingress-smoke run web --image=nginx
kubectl -n ingress-smoke wait --for=condition=ready pod/web --timeout=60s
kubectl -n ingress-smoke expose pod web --port=80
cat <<EOF | kubectl apply -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: smoke
namespace: ingress-smoke
spec:
ingressClassName: nginx
rules:
- host: ${HUB_DOMAIN}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web
port:
number: 80
EOF
sleep 5
echo "==> Resolving Ingress through MetalLB-advertised IP"
curl -s -o /dev/null -w "Smoke test: HTTP %{http_code}\n" \
-H "Host: ${HUB_DOMAIN}" "http://${INGRESS_LB_IP}/"
echo "==> Cleaning up smoke test"
kubectl delete ns ingress-smoke --ignore-not-found
echo
echo "========================================"
echo "ingress-nginx HA + MetalLB install complete"
echo "========================================"
echo
echo "LoadBalancer IP: ${INGRESS_LB_IP}"
echo "DaemonSet running on every node — failover via MetalLB L2 election"
echo
echo "Verify which node currently owns the LB IP:"
echo " kubectl -n metallb-system logs -l component=speaker | grep 'announcing' | tail -10"
echo
echo "DNS: point your wildcard *.example.com A record at ${INGRESS_LB_IP}"
echo
echo "TLS: install cert-manager separately and configure ClusterIssuer for Let's Encrypt"
Make executable and run:
chmod 700 /root/install-ingress-metallb.sh
/root/install-ingress-metallb.sh
Once it returns clean, validate the four states you actually care about. The DaemonSet has one pod per node (kubectl -n ingress-nginx get pods -o wide — count should equal kubectl get nodes count). The Service has an external IP assigned and it’s the one you pinned. The smoke test returned 200. Failover works — drain the node currently announcing the IP (kubectl drain <node> --ignore-daemonsets) and re-run the curl; MetalLB should re-elect within 10 seconds and the curl should still succeed. The most common failure on first install is strictARP not actually being on — the patch logic above is best-effort, so verify with kubectl get configmap -n kube-system kube-proxy -o yaml | grep strictARP. The second most common is the IP range overlapping with DHCP — MetalLB hands out an IP, the upstream router thinks it’s been re-assigned, and you have an intermittent ARP fight. Carve the MetalLB range out of DHCP scope on the upstream router.
We run bare-metal Kubernetes clusters on our managed cloud compute under Managed Cloud Ops with ingress lifecycle, TLS rotation, and MetalLB failover monitoring in our monitoring plane — start a scoping call to scope your cluster.