How to assign an hostname to an Azure Application Gateway with AGIC

8/27/2020

I'm using the Azure Kubernetes Service to deploy a web application on k8s and I'm using the Application Gateway Ingress Controller to forward the requests from the outside of the k8s cluster.

I defined the Ingress in this way:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
    appgw.ingress.kubernetes.io/backend-path-prefix: /
    appgw.ingress.kubernetes.io/use-private-ip: "true"
    appgw.ingress.kubernetes.io/ssl-redirect: "true"
spec:
  tls:
  - hosts:
    - my.hostname.com
    secretName: my-cert
  rules:
  - host: my.hostname.com
    http:
      paths:
      - backend:
          serviceName: my-backend
          servicePort: 80

my-cert is a secret I created that contains a SSL certificate my company bought some time ago that is valid for all the names *.hostname.com (is an example).

Now, if I apply this YAML the AGIC gets configured with the secret (I can see from the AGIC's pod logs that everything is fine) but I cannot access my application at the URL my.hostname.com, neither via HTTP nor via HTTPS.

If, instead, I drop the line host: my.hostname.com from the Ingress definition I can access the application via the Application Gateway's private IP.

Do you know if I have to perform some special operations to assign the hostname to my Application Gateway when using AGIC?

-- gvdm
azure
azure-aks
azure-application-gateway
kubernetes
kubernetes-ingress

1 Answer

8/28/2020

Ok, I found the problem/solution. I only had to assign the my.hostname.com hostname to the private network's IP in the company Domain Controller. This way in the company network the hostname is resolvable to the IP

-- gvdm
Source: StackOverflow