CSS, JS not loading on AKS

5/12/2020

Have an Angular SPA which is dockerized and deployed on aks through helm. I could see the application works as expected when deployed on standalone docker. But when deployed on AKS, dont see the resources loading. When inspecting the logs could see

"GET /" "Mozilla/5.0

where it should have been /abc/a.css, so figured out my ingress is not letting the traffic pass through with the path for my service and tried setting the app-root, multiple rewrite target example. But none seemed to help and below is my ingress.yml

Ingress.yml:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: abc-ingress
  namespace: abc
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/app-root: /abc
spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: fbmdashboardpoc-service
          servicePort: 80
        path: /abc(/|$)(.*)

Thanks is advance

-- Santhosh
angular
azure-aks
kubernetes-ingress
nginx-ingress
url-rewriting

1 Answer

5/12/2020

The issue was with my ingress after configuring deployUrl, also made below changes to my ingress file to get it working

kind: Ingress
metadata:
  name: abc-ingress
  namespace: abc
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/use-regex: "true"
spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: fbmdashboardpoc-service
          servicePort: 80
        path: /abc/(.*)

Hope it helps if others are struck with same issue

-- Santhosh
Source: StackOverflow