What annotations should I add to Kubernetes Ingress to load static resources?

67 views Asked by At

I have an Angular based web service called "competitions-service" and hosted on Kubernetes. This service implements a sport module routed by "/sports"

My goal is to have a hostname "sport.domain.com" pointing to the sport module.

For that, I have the following ingress setup file:

kind: Ingress
metadata:
  name: sports-ingress
  namespace: default
  annotations:
spec:
  ingressClassName: ingress-nginx
  rules:
  - host: sport.domain.com
    http:
      paths:
      - pathType: Prefix
        path: "/sports"
        backend:
          service:
            name: competitions-service
            port:
              number: 80

Now the issue is, when I load "sport.domain.com/sports" into the browser, All the static ressource (runtime.js, polyfills.js, main.js, styles.css, images...) are throwing 404 NOT FOUND error.

From network tab, I can see that they are being fetched by the base url "sport.domain.com" like "sport.domain.com/main.js", which should not be accessible.

Any suggestions which annotations can solve this issue? Or am I on the wrong way?

0

There are 0 answers