Home > other >  AKS with Nginx not available over IP, only DNS
AKS with Nginx not available over IP, only DNS

Time:11-25

I'm trying to make a web application on AKS with a static IP, and naturally found a solution with an Nginx ingress controller in Azure's documentation.

This works well, except for the part with the dns-label. My application is only visible on the <dns-label>.<region>.cloudapp.azure.com, which is of course a bit annoying (can't route my webhosts DNS to a url). Anyhow, it's not available on the static IP I assigned to the cluster, which I find strange. When I ping the IP, it results in a 404 from Nginx. I tried to change the Ingress host, without luck.

When I kubectl describe ingress basic-ingress, everything looks alright:

Name:             basic-ingress
Namespace:        default
Address:          XXXXXXXXXX
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
TLS:
  tls-secret terminates XXXXXXXXXXXXX.XXXXX.cloudapp.azure.com
Rules:
  Host                                    Path  Backends
  ----                                    ----  --------
  platform-dns.eastus.cloudapp.azure.com
                                          /*       smp-frontend:80 (XXXXXXXXX, XXXXXXXX, XXXXXXXXXX)
                                          /api/*   smp-backend:8080 (XXXXXXX, XXXXXXXXX, XXXXXXXX)
Annotations:                              cert-manager.io/cluster-issuer: XXXXXXXXXX
                                          kubernetes.io/ingress.allow-http: true
                                          kubernetes.io/ingress.class: nginx
                                          nginx.ingress.kubernetes.io/rewrite-target: /
Events:
  Type    Reason             Age                From                      Message
  ----    ------             ----               ----                      -------
  Normal  CreateCertificate  84m                cert-manager              Successfully created Certificate "XXXXXXXX"
  Normal  Sync               71m (x4 over 84m)  nginx-ingress-controller  Scheduled for sync
  Normal  Sync               71m (x4 over 84m)  nginx-ingress-controller  Scheduled for sync

CodePudding user response:

Ingress routes Traffic based on hostname (host header within the request; Layer 7). To route Traffic with an IP address only you will have to configure your Ingress manifest to listen on wildcard. You can do so by removing the "host" field in the HTTP rule:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minimal-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - path: /testpath
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80

If you would like to stay with IP only you could also think about moving from Ingress to the LoadBalancer service which directly exposes your workload via an Azure Loadbalancer (Layer 4).

A guide on how to use the LoadBalancer service with a Static IP is available here.

  • Related