traefik on kubernetes


the best way to interact with traefik via kubernetes is using custom resource definitions, instead of the integrated kubernetes ingress controller definitions

  • firstly install traefik crd on kubernetes
  • install rbac for authorize traefik to access to all crd properties

kubectl apply -f https://www.mirkoceroni.it/wp-content/uploads/2024/04/kubernetes-crd-rbac.yaml

  • deploy a sample pod whoami

kubectl apply -f https://www.mirkoceroni.it/wp-content/uploads/2024/04/whoami.yaml

  • deploy traefik pod

kubectl apply -f https://www.mirkoceroni.it/wp-content/uploads/2024/04/traefik.yaml

  • create an ingress for expose whoami service created above through traefik defining the hostname for virtualhosting

kubectl apply -f https://www.mirkoceroni.it/wp-content/uploads/2024/04/ingress.yaml

to list traefik crd ingresses ( aka virtual hosts )

kubectl get ingressroutes.traefik.io