Skip to content

Instantly share code, notes, and snippets.

@joshimoo
Last active March 25, 2021 15:09
Show Gist options
  • Save joshimoo/fe29f74d049a85a35f90f19f7921ea7e to your computer and use it in GitHub Desktop.
Save joshimoo/fe29f74d049a85a35f90f19f7921ea7e to your computer and use it in GitHub Desktop.
Longhorn UI with traeffic / metallb load balancer

https://forums.rancher.com/t/longhorn-ui-with-traefik/16742

I managed it to route the longhorn-ui via my traefik. So I can answer my question by myself. Here is my receipt:

1.) first remove the default service provided by Longhorn deployment: kubectl delete service longhorn-frontend -n longhorn-system

2.) next create a service definition (longhorn-service.yaml)

apiVersion: v1
kind: Service
metadata:
  labels:
    app: longhorn-ui
  name: longhorn-frontend
  namespace: longhorn-system
spec:
  ports:
  - port: 8000
    protocol: TCP
    targetPort: 8000
    name: web
  selector:
    app: longhorn-ui

kubectl apply -f longhorn-service.yaml

3.) define a Ingress for traefik loadBalancer (longhorn-ingress.yaml)

kind: IngressRoute
apiVersion: traefik.containo.us/v1alpha1
metadata:
  name: longhorn-frontend
  namespace: longhorn-system

spec:
  entryPoints: 
    - web
  routes:
  - match: Host(`{YOUR-DNS}`) # Replace the {YOUR-DNS} with a DNS pointing to your cluster
    kind: Rule
    services:
    - name: longhorn-frontend
      port: 8000

kubectl apply -f longhorn-ingress.yaml

Now you can access the longhorn-ui via http://YOUR-DNS/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment