To utilize Azure static website as the backend on ingress, we attempted to utilize the service type as ExternalName. However, this approach proved ineffective, resulting in the following errors:
Warning EndpointsEmpty 9m17s (x58 over 17m) azure/application-gateway Code="ErrorFetchingEndpoints" Message="Endpoint not found for nodepool/xxxblobbackend"
We aim to route static traffic based on different paths, thereby alleviating the load on the primary workload.
We have successfully deployed the application on AKS with Azure Application Gateway as the ingress, and it is performing as anticipated.
Presently, we endeavor to redirect the static content to the Azure Blob static page instead of routing it through our application. Initially, we manually deployed it on the application gateway, which yielded the desired outcome. However, according to Microsoft Documentation, making manual changes on Application Gateway post-integration with AKS is not recommended.
We have also attempted to apply it through the ingress controller, as outlined below, but we got a negative outcome as mentioned above.
apiVersion: v1
kind: Service
metadata:
name: xxxblobbackend
namespace: nodepool
spec:
type: ExternalName
externalName: xxxyyyprod.z16.web.core.windows.net
selector:
app: xxxblobbackend
ports:
- protocol: TCP
port: 443
targetPort: 443
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
appgw.ingress.kubernetes.io/backend-hostname: localhost
appgw.ingress.kubernetes.io/backend-protocol: http
appgw.ingress.kubernetes.io/health-probe-path: /
appgw.ingress.kubernetes.io/request-timeout: "180"
appgw.ingress.kubernetes.io/proxy-body-size: "0"
appgw.ingress.kubernetes.io/proxy-read-timeout: "900"
appgw.ingress.kubernetes.io/proxy-send-timeout: "900"
appgw.ingress.kubernetes.io/ssl-redirect: "true"
kubernetes.io/ingress.class: azure/application-gateway
generation: 5
name: ingress-api
namespace: nodepool
spec:
rules:
- http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: defaultbackend
port:
number: 80
- path: /api/*
pathType: Prefix
backend:
service:
name: api-service
port:
number: 8081
- path: /static/*
pathType: ImplementationSpecific
backend:
service:
name: xxxblobbackend
port:
number: 443
tls:
- secretName: xxxme-yyy-tls-certificate

When integrating an Azure Blob Storage static website with AKS using Azure Application Gateway as the ingress and encountering the "ErrorFetchingEndpoints" issue with a Service of type
ExternalName, a direct approach withExternalNamemight not work as expected due to the way Azure Application Gateway Ingress Controller (AGIC) handles service endpoints. Instead, consider using an Nginx reverse proxy within your cluster to route traffic to the static website. This method bypasses the limitations ofExternalNameservices with AGIC.First, deploy an Nginx pod that acts as a reverse proxy. This pod will forward requests to your Azure Blob Storage static website.
Deployment YAML
ConfigMap for Nginx Configuration
In this configuration,
resolver 8.8.8.8 valid=10s;tells Nginx to use8.8.8.8(Google's DNS) as the resolver with a validity time of 10 seconds for cached DNS lookups. You can replace8.8.8.8with the IP address of your Kubernetes cluster's DNS service if you prefer not to rely on an external service.Next, expose the Nginx reverse proxy through a Kubernetes service within your cluster.
service yaml
Finally, adjust your Ingress resource to route
/static/*paths to the Nginx proxy service. Finally, adjust your Ingress resource to route/static/*paths to the Nginx proxy service.ingress yaml
The original issue was that AGIC could not properly route to the Azure Blob Storage static site using a service of type
ExternalName, resulting in "ErrorFetchingEndpoints" errors. This is because AGIC expects to route traffic to IP endpoints, whichExternalNameservices do not provide directly.Here, in this setup, Nginx acts as a middleman, receiving requests from the ingress and forwarding them to the Azure Blob Storage static site and should route traffic intended for static content to the Azure Blob Storage through an Nginx reverse proxy, circumventing the limitations of
ExternalNamewith AGIC and enabling efficient static content delivery.