I have to write Ingress controller in AKS for multiple deployed service.
Use case.
- I have created the function app images and deployed them in AKS Cluster
- Now Individual service has the endpoints and I tested it individually it’s working fine and giving the response.
Problem:
I have written the ingress controller and used the rewrite-target somehow its works for a single API but when I am using the rewrite-target multiple time then the existing one is not working only the latest one is working.
Code:
kind: Ingress
metadata:
name: test-ingress
namespace: containerpoc
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /api/AccountBalance?account
#nginx.ingress.kubernetes.io/rewrite-target: /api/Refining?account
#nginx.ingress.kubernetes.io/rewrite-target: /api/RefiningDetail?CustRefNum
#nginx.ingress.kubernetes.io/rewrite-target: /api/Transactions?accounts
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /account
pathType: Prefix
backend:
service:
name: accountbalance-service
port:
number: 80
- path: /account/balanceref
pathType: Prefix
backend:
service:
name: accountbalance-service
port:
number: 80
- path: /transaction
pathType: Prefix
backend:
service:
name: transactions-service
port:
number: 80 ```
The above code is working for a single API but I need to make it for multiple API/endpoints
The ask is how to set up the ingress which can support multiple API route-based URL
I am expecting the URL to look like
In browser
IP/Account?account=1
IP/Transaction?account=1
IP/refining?CustomRefnum=&&Ref=2323-oo&DateReceived=03-May-2023&account=0000
Thanks
Sudhir
2
Answers
You can define multiple ingress in different namespace for respective service/url.
Or create new ingress object with different name for each api endpoint.
You can define multiple ingress in different namespace for respective service/url.
Or create new ingress object with different name for each api endpoint.