Skip to content

Trying traefik’s ingress controller

Course: Kubernetes Part 2 - chapter 12

Traefik is another popular ingress controller. Let’s try to our apps using it next

  • Install traefik ingress controller using helm
helm repo add traefik https://helm.traefik.io/traefik
helm repo update
helm install traefik traefi/traefik --namespace traefik --create-namespace
  • Make sure an ingressClass is created for traefik
kubectl get IngressClass
  • Notice it created a LoadBalancer svc for you
kubectl get svc -n traefik
  • Create a Ingress that uses the traefik ingressClass and traefik annotations (traefik.yml)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: traefik-web-apps-ingress
namespace: default
spec:
ingressClassName: traefik
rules:
- host: traefik-domain.com
http:
paths:
- path: /nginx
pathType: Prefix
backend:
service:
name: nginx-service
port:
number: 80
- path: /apache
pathType: Prefix
backend:
service:
name: apache-service
port:
number: 80
  • Add an entry to your /etc/hosts (IP should be your loadbalancer IP)
65.20.90.183 traefik-domain.com
  • Visit the website
traefik-domain.com/nginx
traefik-domain.com/apache

💡

Can you guess what is going wrong? Why are you not seeing anything on this final page?

Try to figure out how can you rewrite the path to / if you’re using traefik as the ingress class