Traefik ingress with kind and metallb

214 views Asked by At

I'm trying to setup Traefik ingress in Kind cluster with Metallb for LoadBalancer services using Ubuntu.

I'm not an expert in networking settings tbh.

Configuration files

# kind-config.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
  - role: control-plane
    kubeadmConfigPatches:
      - |
        kind: InitConfiguration
        nodeRegistration:
          kubeletExtraArgs:
            node-labels: "ingress-ready=true"
    extraPortMappings:
      - containerPort: 80
        hostPort: 80
        protocol: TCP
      - containerPort: 443
        hostPort: 443
        protocol: TCP
  - role: worker
  - role: worker

# metallb.yaml
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: example
  namespace: metallb-system
spec:
  addresses:
    # Got this range from docker network inspect -f '{{.IPAM.Config}}' kind
    - 172.18.255.200-172.18.255.250
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: empty
  namespace: metallb-system
spec:
  ipAddressPools:
    - example
# dashboard.yaml
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: dashboard
spec:
  entryPoints:
    - web
  routes:
    - match: Host(`traefik.localhost`) && (PathPrefix(`/dashboard`) || PathPrefix(`/api`))
      kind: Rule
      services:
        - name: api@internal
          kind: TraefikService

Commands

kind create cluster --config kind-config.yaml
kubectl wait --for=condition=ready node --all --timeout=90s

kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.7/config/manifests/metallb-native.yaml
kubectl wait --namespace=metallb-system --for=condition=ready pod --selector=app=metallb --timeout=90s
kubectl apply -f metallb.yaml

helm repo add traefik https://traefik.github.io/charts
helm repo update
helm install traefik traefik/traefik

kubectl apply -f dashboard.yaml

Results

Traefik dashboard not available at: traefik.localhost:9000/dashboard/

If I do a port-forward for either traefik dashboard service or traefik pod it works fine accessing via localhost:9000/dashboard/

Kubectl Command Outputs

kubectl get svc

NAME         TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)                      AGE
kubernetes   ClusterIP      10.96.0.1       <none>           443/TCP                      25m
traefik      LoadBalancer   10.96.128.168   172.18.255.200   80:32760/TCP,443:30039/TCP   24m

Trying to access IP 172.18.255.200:9000/dashboard/ doesn't work as well.

1

There are 1 answers

0
Natan Deitch On

I was able to make it work mistakes were:

Missing metallb config to use ip address pool:

spec:
  ipAddressPools:
    - example

And then I found out that /etc/hosts doesn't support wildcards domain, so every host rule that relies in subdomains should be declared in /etc/hosts

172.18.255.200 traefik.localhost

With these configs in place everything works fine.