# Update on restricting egress traffic on Azure Kubernetes Service

- URL: https://baeke.info/2019/05/15/update-on-restricting-egress-traffic-on-azure-kubernetes-service/
- Author: Geert Baeke
- Published: May 15, 2019 (updated March 12, 2025)
- Topics: Azure, Containers, Kubernetes
- Outdated: The preview feature it registers no longer exists; see the current AKS docs on controlling egress traffic.

In an [earlier post](https://baeke.info/2019/05/03/azure-kubernetes-service-and-azure-firewall/), I discussed the combination of Azure Firewall and Azure Kubernetes Service (AKS) to secure ingress and egress AKS traffic.

A few days ago, Microsoft added [documentation](https://docs.microsoft.com/en-us/azure/aks/limit-egress-traffic) that describes the ports and URLs to allow when you route traffic through Azure Firewall or a virtual appliance. Some of the allowed ports and addresses are [required](https://docs.microsoft.com/en-us/azure/aks/limit-egress-traffic#required-ports-and-addresses-for-aks-clusters) for the operation of the cluster, while some others are [optional](https://docs.microsoft.com/en-us/azure/aks/limit-egress-traffic#optional-recommended-addresses-and-ports-for-aks-clusters). It’s highly recommended to allow the optional ports and addresses though.

The [top](https://docs.microsoft.com/en-us/azure/aks/limit-egress-traffic#optional-recommended-addresses-and-ports-for-aks-clusters) of the document mentions registering an additional feature called **AKSLockingDownEgressPreview**:

```bash
az feature register --name AKSLockingDownEgressPreview --namespace Microsoft.ContainerService
```

The document is not very clear on what the feature does but the comments contain the following:

```
The feature registration tells the cluster to only pull core system images from container image repositories housed in the Microsoft Container Registry (MCR). Otherwise, clusters could try to pull container images for the core components from external repositories. There is some additional routing that also occurs for the cluster to do this. The list of ports and addresses are then what's required for you to permit when the egress traffic is restricted. You can't simply limit the egress traffic to only those address without the feature being enabled for the cluster.
```

In summary, to limit egress traffic, use Azure Firewall or a Network Virtual Appliance, allow the listed ports and URLs AND register the AKSLockingDownEgressPreview feature.
