Hi, I am trying to add basic auth to my ingress exposing my longhorn UI. All this runs on a k3s Cluster.
I Create the secret with the following yaml:
apiVersion: v1
kind: Secret
metadata:
name: longhorn-auth
namespace: longhorn-system
data:
users: |2
base64encodedsecrets
And these are my Middleware and ingress configuration:
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: ingressauth
namespace: longhorn-system
spec:
basicAuth:
secret: loghorn-auth
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
kubernetes.io/ingress.class: traefik
traefik.ingress.kubernetes.io/router.middlewares: longhorn-system-ingressauth@kubernetescrd
name: longhorn-ingress
namespace: longhorn-system
spec:
rules:
- host: longhorn.example.com
http:
paths:
- backend:
service:
name: longhorn-frontend
port:
number: 80
path: /
pathType: Prefix
tls:
- hosts:
- longhorn.example.com
secretName: longhorn-cert
Without the last annotation I can access the longhorn UI but it is unprotected. With this configuration I get an 404 Error with my browser and the log states the following:
time="2021-03-11T22:54:38Z" level=error msg="Error while reading basic auth middleware: failed to load auth credentials: secret 'longhorn-system/loghorn-auth' not found" middlewareName=longhorn-system-ingressauth providerName=kubernetescrd
Moving the secret to the same namespace as traefik also does not work. Can you guess why it can not find the secret.
Thanks
Clemens