Web Application Routing on AKS
Tags: cloudnative, kubernetes, nginx, ingress
Published: 2022-11-16 19:16:47

---
title: Web Application Routing on AKS
published: true
date: 2022-11-16 14:00:00 UTC
tags: cloudnative, kubernetes, nginx, ingress
canonical_url: https://paulyu.dev/article/managed-ingress-on-aks/
---

Exposing your web applications on [Azure Kubernetes Service (AKS)](https://learn.microsoft.com/azure/aks/intro-kubernetes) has gotten a little bit easier. In this post, I will cover the new [Web Application Routing](https://learn.microsoft.com/azure/aks/web-app-routing?tabs=with-osm) feature for AKS and discuss reasons why you may want to implement it within your cluster.

## Exposing your app

You have a lot of options when it comes to exposing your application **Pods** to the world. If you're using a managed-Kubernetes service in the cloud, you could deploy a [Service](https://kubernetes.io/docs/concepts/services-networking/service/) and set the type to [LoadBalancer](https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer) and your cloud provider will provision one with a public IP. The **Service** sits in front of your **Pods** and if all you need is a public IP, you're good to go.

Most use cases aren't that simple. You may need to expose HTTP(S) traffic and do some more advanced things like SSL/TLS termination or direct traffic to specific pods based on routing rules. For this, an [Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) is a commonly used. The **Ingress** sits in front of your **Service** and requires an [Ingress Controller](https://kubernetes.io/docs/concepts/services-networking/ingress-controllers) to satisfy requests.

## Ingress options on AKS

With AKS, you have a few options for Ingress:

1. Deploy your own open-source [ingress controller][aks_ingress_nginx]. Most opt for [Kubernetes Ingress][k8s_ingress_nginx] which is built on open-source NGINX, but installation and support will come from you and/or the community.
2. Deploy the [AKS HTTP application routing add-on][aks_ingress_http_addon] which is essentially a managed version of Kubernetes Ingress mentioned above. This will save you the work of installing the resource in your cluster; however, this is **not** intended for production scenarios.
3. Deploy the [Azure Application Gateway Ingress Controller (AGIC)][aks_ingress_agic] which leverages the [Azure Application Gateway](https://azure.microsoft.com/services/application-gateway/) service. The Application Gateway service will be supported by Azure; however, installation and maintenance of the ingress controller will be your responsibility.
4. Deploy the [AKS AGIC add-on][aks_ingress_agic_addon] in which case the ingress controller will be managed and supported by Azure.

So there are two "bring-your-own" (BYO) ingress options and two AKS-managed options. Here "managed" sounds appealing, but when it comes to "managed" options, AGIC sounds like the only choice. And for those that are coming from OSS ingress, the differences between [AGIC annotations](https://azure.github.io/application-gateway-kubernetes-ingress/annotations/) and [NGINX annotations](https://docs.nginx.com/nginx-ingress-controller/configuration/ingress-resources/advanced-configuration-with-annotations/) might be a deal-breaker.

Now what? Well... there's one more "managed" option and it just might check all the right boxes 😊

## Web Application Routing Add-On

The [Web Application Routing add-on][aks_ingress_war_addon] for AKS was announced at [Microsoft Build 2022](https://learn.microsoft.com/events/build-2022/). At the time of this writing the add-on is still in Public Preview; which means you should explore it but it's not intended for production workloads just yet... unless you like living on the edge 😅 But here are four reasons why you should consider it once it becomes Generally Available.

### Managed NGINX ingress controller

First, the add-on will provide you with a highly-available, managed Kubernetes Ingress based on [open-source NGINX][k8s_ingress_nginx]. This is similar to the [HTTP application routing add-on][aks_ingress_http_addon] but is intended for production use and will be fully supported by Azure.

### Manages DNS records

Second, the add-on provides an optional integration with [Azure DNS](https://learn.microsoft.com/azure/dns/dns-overview) and uses an [`external-dns` controller](https://github.com/kubernetes-incubator/external-dns) to manage DNS records on your behalf. The older "HTTP application routing add-on" also provided this functionality;  however, the difference here is that the new add-on can link to your custom Azure DNS resource.

As an example, let's say you have a custom domain called `myawesomesite.com` and delegated it to your Azure DNS resource's nameservers. When you deploy an Ingress with a host name of `store.myawesomesite.com`, an [A record](https://support.dnsimple.com/articles/a-record/) will automatically be added to your Azure DNS resource to point the `store` subdomain to the Ingress' public IP.

### Manages TLS certificates

Third, the add-on provides another optional integration with [Azure Key Vault](https://learn.microsoft.com/azure/key-vault/general/overview) using the [`azure-keyvault-secrets-provider`](https://learn.microsoft.com/azure/aks/csi-secrets-store-driver) AKS add-on. When combined with the Web Application Routing add-on, the ingress controller will be able to load TLS certificates from Azure Key Vault and save it as a [Kubernetes TLS secret](https://kubernetes.io/docs/concepts/configuration/secret/#tls-secrets) with secret rotation.

As an example, if you have a TLS certificate for `store.myawesomesite.com`, simply upload the `.pfx` file to Azure Key Vault and bind the certificate to the Ingress using the [`kubernetes.azure.com/tls-cert-keyvault-uri`](https://github.com/Azure-Samples/azure-opensource-labs/blob/main/cloud-native/aks-webapp-routing/deployment.yaml#L99) annotation.

### Integrates with Open Service Mesh (OSM)

Finally, if you have security requirements such as needing end-to-end encryption between your Ingress and your backend pods, there is out-of-the-box support for [Open Service Mesh (OSM)](https://openservicemesh.io/). OSM is an open-source light-weight service mesh to help secure intra-cluster communications.

In most cases, TLS termination is done at the ingress, and traffic flows un-encrypted to the backend pods. With OSM, you can configure it to proxy connections between Ingress and IngressBackends using mutual TLS (mTLS). This ensures traffic is encrypted all the way down.

OSM can be manually installed and [configured for NGINX](https://release-v1-2.docs.openservicemesh.io/docs/demos/ingress_k8s_nginx/#https-ingress-mtls-and-tls). However, if you combine the [OSM add-on](https://learn.microsoft.com/azure/aks/open-service-mesh-about) with the Web Application Routing add-on, configuration for NGINX is automatically added for you 🥳

## Summary

The Web Application Routing add-on for AKS can be thought of as an evolution to the original [HTTP application routing add-on][aks_ingress_http_addon] with a additional capabilities that make it "production-ready". The goal of this add-on is to make it easier for you to expose your application to the world in a secure manner while reducing some of the operational overhead that goes into that.

## Get hands-on

If you'd like to dive deeper into this feature, check out the resources listed below. In addition to the [docs][aks_ingress_war_addon], you can head over to the [Web Application Routing with Azure Kubernetes Service](https://bit.ly/aks-webapp-routing) lab in the [OSS Labs Repo](https://aka.ms/oss-labs) and take it for a spin.

As always, let me know what you think in the comments below or via [Twitter @pauldotyu](https://twitter.com/pauldotyu). I'd love to hear your feedback on this.

Til next time, cheers!

## Resources

* [Web Application Routing (Preview)][aks_ingress_war_addon]
* [Open Service Mesh AKS add-on](https://learn.microsoft.com/azure/aks/open-service-mesh-about)
* [OSS Lab: Web Application Routing with Azure Kubernetes Service](https://bit.ly/aks-webapp-routing)

<!-- -->
[k8s_ingress_nginx]:https://kubernetes.github.io/ingress-nginx/
[aks_ingress_nginx]:https://learn.microsoft.com/azure/aks/ingress-basic?tabs=azure-cli
[aks_ingress_http_addon]:https://learn.microsoft.com/azure/aks/http-application-routing
[aks_ingress_agic]:https://learn.microsoft.com/azure/application-gateway/ingress-controller-overview
[aks_ingress_agic_addon]:https://learn.microsoft.com/azure/application-gateway/tutorial-ingress-controller-add-on-existing?toc=https%3A%2F%2Flearn.microsoft.com%2Fazure%2Faks%2Ftoc.json&bc=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fazure%2Fbread%2Ftoc.json
[aks_ingress_war_addon]:https://learn.microsoft.com/azure/aks/web-app-routing?tabs=with-osm