Kubernetes : Failed to retrieve auth configuration for ingress

12/27/2018

I have a new kubernetes cluster, I installed Traefik v1.7.6 on it and enabled Traefik dashboard which is working fine.

Now I want to add basic auth on the ingress service of traefik dashboard, I followed docs :

  • created a secret called auth-traefik from htpasswd generated file in same namespace as Traefik
  • added following annotations to ingress dashboard:

    kubernetes.io/ingress.class: traefik
    traefik.ingress.kubernetes.io/auth-secret: auth-traefik
    traefik.ingress.kubernetes.io/auth-type: basic

I can't access the dashboard anymore and got the following page: 502 Bad Gateway nginx/1.13.12

I restarted traefik pod and there is the following log :

*{"level":"error","msg":"Failed to retrieve auth configuration for ingress kube-system/traefik-dashboard: failed to load auth credentials: secret \"kube-system\"/\"auth-traefik\" not found","time":"2018-12-26T23:45:59Z"}*

More details: Ubuntu 18.04 running on a x64 Scaleway server. I tried a regular & MicroK8s installation, both have the same issue (I'm going on with the MicroK8s one, for now).

Traefik was installed through the latest Helm package (with default values, I only enabled the dashboard)

-- MrLuje
basic-authentication
kubernetes
traefik

1 Answer

12/27/2018

Looks like you might have created the auth-traefik Kubernetes secret on a different namespace from kube-system where it's looking for it. (Looks like the Ingress is defined in the kube-system namespace).

You can check with:

$ kubectl -n kube-system get secret auth-traefik -o=yaml

If it's not there (is it in a different namespace? monitoring? default?), then you can create it:

$ kubectl create secret generic auth-traefik --from-file auth --namespace=kube-system

Or the ServiceAccount that your Traefik pod is using doesn't have RBAC access to the Secrets resource in the `kube-system namespace.

-- Rico
Source: StackOverflow