Sidekiq UI loading wrong assets path in Kubernetes path based routing Sidekiq UI loading wrong assets path in Kubernetes path based routing kubernetes kubernetes

Sidekiq UI loading wrong assets path in Kubernetes path based routing


You can have a look at the thread I raised with sidekiq team "Sidekiq Route Mount doesn't rewrite URL in Rails API" that helped me understand how sidekiq mount "/sidekiq" works.

I have a simple work around for this problem and found it to be the best way to resolve my path based routing issue. You can do this using nginx.ingress.kubernetes.io/rewrite-target annotations in your Ingress configurations by writing 2 Ingress rules as shown below:

  1. Routing the "/" path to the root path of the rails-app-service ( xyz.com/* -> rails-app-service/* )

  2. Routing the "/sidekiq" path to the sidekiq web mount path of the rails-app-service ( xyz.com/sidekiq/* -> rails-app-service/sidekiq/* )

To know more about Nginx Ingress Controller rewrite target annotation check the official repository for details: https://github.com/kubernetes/ingress-nginx/tree/master/docs/examples/rewrite#rewrite-target

This is my final code snippet with the solution:

apiVersion: extensions/v1beta1kind: Ingressmetadata:  name: "rails-app-ingress"  annotations:    kubernetes.io/ingress.class: nginx    nginx.ingress.kubernetes.io/ssl-redirect: "false"    nginx.ingress.kubernetes.io/rewrite-target: /spec:  rules:  - host: xyz.com    http:      paths:      - path: /        backend:          serviceName: "rails-app-service"          servicePort: 80---apiVersion: extensions/v1beta1kind: Ingressmetadata:  name: "rails-sidekiq-ingress"  annotations:    kubernetes.io/ingress.class: nginx    nginx.ingress.kubernetes.io/ssl-redirect: "false"    nginx.ingress.kubernetes.io/rewrite-target: /sidekiqspec:  rules:  - host: xyz.com    http:      paths:       - path: /sidekiq        backend:          serviceName: "rails-app-service"          servicePort: 80