Reputation: 43
Need help on setting up the ingress in K8S. Thank you in advance.
I have configured, NGINX Controller and Cert-Manager on the AKS cluster using Helm.
Next - deployed two pods, and respected services here are those names and can be found in the above-attached image.
Next - when I try to set up the ingress like below for the above two services.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: rpe-delivers-orders-dcs-ingress
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: dcs-cluster-issuer
nginx.ingress.kubernetes.io/rewrite-target: /$1
nginx.ingress.kubernetes.io/use-regex: "true"
spec:
tls:
- hosts:
- raag.westus2.cloudapp.azure.com
secretName: dcs-tls-secret
rules:
- host: raag.westus2.cloudapp.azure.com
http:
paths:
- path: /orders-dcs(/|$)(.*)
pathType: Prefix
backend:
service:
name: rpe-delivers-orders-dcs-api
port:
number: 80
- path: /orders-proxy(/|$)(.*)
pathType: Prefix
backend:
service:
name: rpe-delivers-orders-proxy-api
port:
number: 80
- path: /(.*)
pathType: Prefix
backend:
service:
name: rpe-delivers-orders-dcs-api
port:
number: 80
My goal is for the below URLs should redirect to two different web pages:
Please let me know if I'm missing any information or didn't do the setup right.
Thank you.
Upvotes: 2
Views: 457
Reputation: 30113
Looks like you are missing the block of rpe-delivers-orders-proxy-api
in your ingress config
- path: /(.*)
pathType: Prefix
backend:
service:
name: rpe-delivers-orders-proxy-api
port:
number: 80
If you have any path rewrite option and requirement in that case you can create the two different ingress
No 1. rewrite ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-first
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: dcs-cluster-issuer
nginx.ingress.kubernetes.io/rewrite-target: /$1
nginx.ingress.kubernetes.io/use-regex: "true"
spec:
tls:
- hosts:
- raag.westus2.cloudapp.azure.com
secretName: dcs-tls-secret
rules:
- host: raag.westus2.cloudapp.azure.com
http:
paths:
- path: /orders-dcs(/|$)(.*)
pathType: Prefix
backend:
service:
name: rpe-delivers-orders-dcs-api
port:
number: 80
- path: /orders-proxy(/|$)(.*)
pathType: Prefix
backend:
service:
name: rpe-delivers-orders-proxy-api
port:
number: 80
No 2. simple ingress which will be also there as per your requirement
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-second
annotations:
kubernetes.io/ingress.class: nginx
spec:
tls:
- hosts:
- raag.westus2.cloudapp.azure.com
secretName: dcs-tls-secret
rules:
- host: raag.westus2.cloudapp.azure.com
http:
paths:
- path: /
backend:
service:
name: rpe-delivers-orders-proxy-api
port:
number: 80
- path: /
backend:
service:
name: rpe-delivers-orders-dcs-api
port:
number: 80
Update :
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-second
annotations:
kubernetes.io/ingress.class: nginx
spec:
tls:
- hosts:
- raag.westus2.cloudapp.azure.com
secretName: dcs-tls-secret
rules:
- host: raag.westus2.cloudapp.azure.com
http:
paths:
- path: /orders-proxy
pathType: Prefix
backend:
service:
name: rpe-delivers-orders-proxy-api
port:
number: 80
Upvotes: 1