How to expose Linkerd dashboard via Ingress

5/21/2021

I have a 3 node K3s cluster with Linkerd and NGINX Ingress Controller. I installed Linkerd with a default configuration:

linkerd install | kubectl apply -f -

Then to install the NGINX Ingress Controller I used helm with a default configuration as well:

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update

helm install ingress-nginx ingress-nginx/ingress-nginx

I can access the Linkerd dashboard by calling linkerd viz dashboard, but I'd like to expose the dashboard with an Ingress definition. I modified the example yaml file from Linkerd's website located here, so that I could use a prefix path. In the end, my yaml file looked like this:

apiVersion: v1
kind: Secret
type: Opaque
metadata:
  name: web-ingress-auth
  namespace: linkerd-viz
data:
  auth: YWRtaW46JGFwcjEkbjdDdTZnSGwkRTQ3b2dmN0NPOE5SWWpFakJPa1dNLgoK
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: web-ingress
  namespace: linkerd-viz
  annotations:
    kubernetes.io/ingress.class: 'nginx'
    nginx.ingress.kubernetes.io/upstream-vhost: $service_name.$namespace.svc.cluster.local:8084
    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_set_header Origin "";
      proxy_hide_header l5d-remote-ip;
      proxy_hide_header l5d-server-id;      
    nginx.ingress.kubernetes.io/auth-type: basic
    nginx.ingress.kubernetes.io/auth-secret: web-ingress-auth
    nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required'
spec:
  rules:
  - http:
      paths:
        - path: /linkerd
          pathType: Prefix
          backend:
            serviceName: web
            servicePort: 8084

For any of my other custom microservices, I can simply access them via the public IP address of my nginx ingress service. I can get this IP like this:

kubectl describe svc ingress-nginx-controller | grep "LoadBalancer Ingress" | awk '{ print $3 }'

When I try accessing the dashboard at http://EXPOSED_IP/linkerd, I am prompted to enter my username and password (both admin by default), but then I get a 404 not found error.

Does anybody know what could be the issue? Thank you very much!

-- Brent Redmon
kubernetes
kubernetes-helm
kubernetes-ingress
linkerd
nginx-ingress

1 Answer

5/21/2021

It's never going to like the path. It needs to serve on the root of the url. So change path to '/' and it should work fine. I'm happy to try it out locally if that doesn't work.

-- Jason Morgan
Source: StackOverflow