AKS Ingress works with IP and DNS label but not with Cloudflare DNS Record
So, I created an AKS cluster with 2 deployments:
- C# RESTfull API
- C# YARP API Gateway
both have ClusterIP services. I added nginx ingress controller to my cluster and created an ingress component in namespaces where the pods and services of my deployments are running and it looks like this:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: api-gateway-ingress
namespace: apps
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
cert-manager.io/cluster-issuer: letsencrypt-staging
kubernetes.io/tls-acme: "true"
spec:
ingressClassName: nginx
rules:
- host: myhost.hr
- http:
paths:
- path: /api(/|$)(.*)
pathType: Prefix
backend:
service:
name: api-gateway-service
port:
number: 3000
- path: /(/|$)(.*)
pathType: Prefix
backend:
service:
name: aks-helloworld-two
port:
number: 80
tls:
- hosts:
- myhost.hr
secretName: letsencrypt-staging
I got my IP address and my host in Azure portal "Ingresses" on Kubernetes cluster a even went so far as to configure the DNS label for that IP address-
and this worked if I went to http://{ingressIp}/api/{endpoint} I get the response same as for http://{azureDnsLabel}/api/{endpoint} everything works as expected.
Then the next step was to go to Cloudflare and configure the DNS record that I did creating the CNAME entry that points to my Azure DNS label. Also, I created the Cert manager and ClusterIssuer in my AKS as a part of debugging the issue:
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-staging
namespace: cert-manager
spec:
acme:
email: