traefik: traefik doesn't respect kubernetes.io/ingress.class

traefik: 1.1.2 kubernetes: 1.5.2 OS: ubuntu 14.04

Test kubernetes deployment, service, ingress:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: nginx
  name: nginx
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: nginx
  type: ClusterIP

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80

---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nginx
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: example.com
    http:
      paths:
      - path:
        backend:
          serviceName: nginx
          servicePort: 80

Important: There is metadata.annotations: kubernetes.io/ingress.class: "nginx" in ingress.

Instead of skip this ingress (kubernetes.io/ingress.class: "nginx") traefik is processing it and adding frontend and backend:

# curl -s 127.0.01:8080/api | jq '.kubernetes.frontends["example"]'
{
  "priority": 0,
  "passHostHeader": true,
  "routes": {
    "example.com": {
      "rule": "Host:example.com"
    }
  },
  "backend": "example.com",
  "entryPoints": [
    "http"
  ]
}
# curl -s 127.0.0.1:8080/api | jq '.kubernetes.backends["example.com"]'
{
  "loadBalancer": {
    "method": "wrr"
  },
  "servers": {
    "nginx-1691775941-kpx47": {
      "weight": 0,
      "url": "http://10.200.70.23:80"
    }
  }
}

Traefik should ship this ingress because of kubernetes.io/ingress.class: "nginx".

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 23 (11 by maintainers)

Most upvoted comments

@Regner FWIW, the Nginx controller also accepts Ingress resources where the annotation value is an empty string. From the docs:

Setting the annotation kubernetes.io/ingress.class to any value other than “nginx” or the empty string, will force the NGINX Ingress controller to ignore your Ingress.

I think there’s value in being consistent with Nginx’s rule unless we have reason to believe it doesn’t make sense for us. For me personally, the empty string is “functionally equivalent” to having no annotation at all.