Migration
From ingress-nginx to Traefik
This guide will help you migrate your Kubernetes cluster from using ingress-nginx to Traefik as your ingress controller.
For a comprehensive, official guide with detailed instructions and troubleshooting, refer to the Traefik documentation on migrating from ingress-nginx.
Prerequisites
- Kubernetes cluster with ingress-nginx installed
- kubectl configured to access your cluster
- kubectl-ns plugin installed
- Access to DNS manager
Install Traefik
Add the Traefik Helm repository:
task add-reposInstall Traefik:
task install-traefikCheck that Traefik is running:
kubectl get pods -n traefikEnsure traefik is the new default.
kubectl get ingressclass traefik -o jsonpath='{.metadata.annotations.ingressclass\.kubernetes\.io/is-default-class}'List the service.
kubectl get svc -n traefikNote that the Treafik service has a different external IP address.
traefik_service_ip=$(kubectl get svc -n traefik traefik -o jsonpath='{.status.loadBalancer.ingress[0].ip}')Update Ingress Resource
Switch to namespace with ingress:
kubectl-nsPatch the ingress resource:
kubectl patch ingress $name -p '{"spec":{"ingressClassName":"traefik"}}'Verify the patch:
kubectl get ingress $name -o yaml | grep -A1 ingressClassNameVerify that your application is accessible through Traefik:
curl -I -H "Host: app.example.com" http://$traefik_service_ipTo route it externally we need to update the application's DNS entry.
You can also update all ingress resources at once.
kubectl get ingress --all-namespacesPatch all ingresses to use Traefik:
kubectl get ingress --all-namespaces -o jsonpath='{range .items[*]}{.metadata.name}{" "}{.metadata.namespace}{"\n"}{end}' | while read name namespace; do kubectl patch ingress "$name" -n "$namespace" -p '{"spec":{"ingressClassName":"traefik"}}'; doneUpdate DNS
Update DNS entries of your applications to point to the new Treafik IP.
Ensure the new IP address is resolved.
nslookup app.example.com 9.9.9.9Verify that your applications is routed correctly:
curl -I https://app.example.comUpgrade Cluster Issuer
If you deployed a cluster issuer, update the release:
task upgrade-chart clusterIssuer $valuesUninstall ingress-nginx
Once you've verified that Traefik is working correctly, you can uninstall ingress-nginx:
kubectl-ns ingress-nginx
task uninstall-release ingress-nginx