I'm setting up my Kubernetes Cluster using Azure AKS and I deployed NGINX Ingress following this guide: https://docs.microsoft.com/en-us/azure/aks/ingress-internal-ip
Now the guide works great for the demo applications it demonstrates on but when I tried deploying one of my own apps the page only showed the html parts and for the js, css and png parts I got the following errors in the Console:
When I deploy the application without NGINX Ingress on my K8S cluster it works perfectly but for some reason when I deploy it through NGINX I get these errors.
I also tried deploying another app, pgAdmin, and for that I only receive an error 503 when I try to approach its' page.
I tried several workarounds I found on the web but nothing seemed to fix it.
Files:
internal-ingress.yaml:
controller:
service:
loadBalancerIP: 10.50.0.253
annotations:
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
hello-world-ingress.yaml:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: hello-world-ingress
namespace: infra
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- http:
paths:
- backend:
serviceName: aks-helloworld
servicePort: 80
path: /hello-world-one(/|$)(.*)
- backend:
serviceName: pgadmin
servicePort: 80
path: /pgadmin(/|$)(.*)
- backend:
serviceName: pgadmin
servicePort: 80
path: /(.*)
- backend:
serviceName: box-model
servicePort: 80
path: /box-model(/|$)(.*)
pgadmin deployment yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.pgadmin.name }}
spec:
selector:
matchLabels:
app: {{.Values.pgadmin.name}}
replicas: {{.Values.pgadmin.deployment.replicas}}
strategy:
type: {{.Values.pgadmin.deployment.strategy}}
template:
metadata:
labels:
app: {{.Values.pgadmin.name}}
spec:
containers:
- env:
- name: PGADMIN_DEFAULT_EMAIL
valueFrom:
secretKeyRef:
name: {{.Values.pgadmin.secrets.PGADMIN_DEFAULT_EMAIL.name}}
key: {{.Values.pgadmin.secrets.PGADMIN_DEFAULT_EMAIL.key}}
- name: PGADMIN_DEFAULT_PASSWORD
valueFrom:
secretKeyRef:
name: {{.Values.pgadmin.secrets.PGADMIN_DEFAULT_PASSWORD.name}}
key: {{.Values.pgadmin.secrets.PGADMIN_DEFAULT_PASSWORD.key}}
image: {{.Values.pgadmin.deployment.image}}
imagePullPolicy: {{.Values.pgadmin.deployment.imagePullPolicy}}
name: {{.Values.pgadmin.name}}
ports:
- containerPort: {{.Values.pgadmin.deployment.containerPort}}
volumeMounts:
- mountPath: {{.Values.pgadmin.deployment.volumeMounts.name}}
name: {{.Values.pgadmin.deployment.volumeMounts.name}}
resources: {}
restartPolicy: {{.Values.pgadmin.deployment.restartPolicy}}
serviceAccountName: ""
volumes:
- name: {{.Values.pgadmin.volumes.pvc.name}}
persistentVolumeClaim:
claimName: {{.Values.pgadmin.volumes.pvc.name}}
status: {}
pgadmin service yaml:
apiVersion: v1
kind: Service
metadata:
name: {{.Values.pgadmin.name}}
spec:
ports:
- name: {{.Values.pgadmin.deployment.containerPort | quote}}
port: {{.Values.pgadmin.deployment.containerPort}}
targetPort: {{.Values.pgadmin.deployment.containerPort}}
status:
loadBalancer: {}
Please tell me if a relevant information is missing and I will add it.
May be nginx.ingress.kubernetes.io/rewrite-target: /$1 is creating an issue. I am not sure.