|
| 1 | +--- |
| 2 | +title: Best practices for Windows containers on Azure Kubernetes Service (AKS) |
| 3 | +description: Learn about best practices for running Windows containers in Azure Kubernetes Service (AKS). |
| 4 | +ms.service: azure-kubernetes-service |
| 5 | +ms.author: schaffererin |
| 6 | +ms.topic: article |
| 7 | +ms.date: 10/27/2023 |
| 8 | +--- |
| 9 | + |
| 10 | +# Best practices for Windows containers on Azure Kubernetes Service (AKS) |
| 11 | + |
| 12 | +In AKS, you can create node pools that run Linux or Windows Server as the operating system (OS) on the nodes. Windows Server nodes can run native Windows container applications, such as .NET Framework. The Linux OS and Windows OS have different container support and configuration considerations. For more information, see [Windows container considerations in Kubernetes][windows-vs-linux]. |
| 13 | + |
| 14 | +This article outlines best practices for running Windows containers on AKS. |
| 15 | + |
| 16 | +## Create an AKS cluster with Linux and Windows node pools |
| 17 | + |
| 18 | +When you create a new AKS cluster, the Azure platform creates a Linux node pool by default. This node pool contains system services needed for the cluster to function. Azure also creates and manages a control plane abstracted from the user, which means you aren't exposed to the underlying OS of the nodes hosting the main control plane components. We recommend that you run at least *two nodes* on the default Linux node pool to ensure the reliability and performance of your cluster. You can't delete the default Linux node pool unless you delete the entire cluster. |
| 19 | + |
| 20 | +There are some cases where you should consider deploying a Linux node pool when planning to run Windows-based workloads on your AKS cluster, such as: |
| 21 | + |
| 22 | +* If you want to run Linux and Windows workloads, you can deploy a Linux node pool and a Windows node pool in the same cluster. |
| 23 | +* If you want to deploy infrastructure-related components based on Linux, such as NGINX, you need a Linux node pool alongside your Windows node pool. You can use control plane nodes for development and testing scenarios. For production workloads, we recommend that you deploy separate Linux node pools to ensure reliability and performance. |
| 24 | + |
| 25 | +## Modernize existing applications with Windows on AKS |
| 26 | + |
| 27 | +You might want to containerize existing applications and run them using Windows on AKS. Before starting the containerization process, it's important to understand the application architecture and dependencies. For more information, see [Containerize existing applications using Windows containers](/virtualization/windowscontainers/quick-start/lift-shift-to-containers). |
| 28 | + |
| 29 | +## Windows OS version |
| 30 | + |
| 31 | +> **Best practice guidance** |
| 32 | +> |
| 33 | +> Windows Server 2022 provides the latest security and performance improvements and is the recommended OS for Windows node pools on AKS. |
| 34 | +
|
| 35 | +AKS uses Windows Server 2019 and Windows Server 2022 as the host OS versions and only supports process isolation. AKS doesn't support container images built by other versions of Windows Server. For more information, see [Windows container version compatibility](/virtualization/windowscontainers/deploy-containers/version-compatibility). |
| 36 | + |
| 37 | +Windows Server 2022 is the default OS for Kubernetes version 1.25 and later. Windows Server 2019 will retire after Kubernetes version 1.32 reaches end of life (EOL) and won't be supported in future releases. For more information, see the [AKS release notes][aks-release-notes]. |
| 38 | + |
| 39 | +## Networking |
| 40 | + |
| 41 | +### Networking modes |
| 42 | + |
| 43 | +> **Best practice guidance** |
| 44 | +> |
| 45 | +> AKS clusters with Windows node pools only support Azure Container Networking Interface (Azure CNI) and use it by default. |
| 46 | +
|
| 47 | +Windows doesn't support kubenet networking. AKS clusters with Windows node pools must use Azure CNI. For more information, see [Network concepts for applications in AKS][network-concepts-for-aks-applications]. |
| 48 | + |
| 49 | +Azure CNI offers two networking modes based on your workload requirements: |
| 50 | + |
| 51 | +* [**Azure CNI Overlay**][azure-cni-overlay] is an overlay network similar to kubenet. The overlay network allows you to use virtual network (VNet) IPs for nodes and private address spaces for pods within those nodes that you can reuse across the cluster. Azure CNI Overlay is the **recommended networking mode**. It provides simplified network configuration and management and the best scalability in AKS networking. |
| 52 | +* [**Azure CNI with Dynamic IP Allocation**][azure-cni-dynamic-ip-allocation] requires extra planning and consideration for IP address management. This mode provides VNet IPs for nodes *and* pods. This configuration allows you direct access to pod IPs. However, it comes with increased complexity and reduced scalability. |
| 53 | + |
| 54 | +To help you decide which networking mode to use, see [Choosing a network model][azure-cni-choose-network-model]. |
| 55 | + |
| 56 | +### Network policies |
| 57 | + |
| 58 | +> **Best practice guidance** |
| 59 | +> |
| 60 | +> Use network policies to secure traffic between pods. Windows supports Azure Network Policy Manager and Calico Network Policy. For more information, see [Differences between Azure Network Policy Manager and Calico Network Policy][azurenpm-vs-calico]. |
| 61 | +
|
| 62 | +When managing traffic between pods, you should apply the principle of least privilege. The Network Policy feature in Kubernetes allows you to define and enforce ingress and egress traffic rules between the pods in your cluster. For more information, see [Secure traffic between pods using network policies in AKS][network-policies-aks]. |
| 63 | + |
| 64 | +Windows pods on AKS clusters that use the Calico Network Policy enable [Floating IP][dsr] by default. |
| 65 | + |
| 66 | +## Upgrades and updates |
| 67 | + |
| 68 | +It's important to keep your Windows environment up-to-date to ensure your systems have the latest security updates, feature sets, and compliance requirements. In a Kubernetes environment like AKS, you need to maintain the Kubernetes version, Windows nodes, and Windows container images and pods. |
| 69 | + |
| 70 | +### Kubernetes version upgrades |
| 71 | + |
| 72 | +As a managed Kubernetes service, AKS provides the necessary tools to upgrade your cluster to the latest Kubernetes version. For more information, see [Upgrade an AKS cluster][upgrade-aks-cluster]. |
| 73 | + |
| 74 | +### Windows node monthly updates |
| 75 | + |
| 76 | +Windows nodes on AKS follow a monthly update schedule. Every month, AKS creates a new VHD with the latest available updates for Windows node pools. The VHD includes the host image, latest Nano Server image, latest Server Core image, and container. We recommend performing monthly updates to your Windows node pools to ensure your nodes have the latest security patches. For more information, see [Upgrade AKS node images][upgrade-aks-node-images]. |
| 77 | + |
| 78 | +> [!NOTE] |
| 79 | +> Upgrades on Windows systems include both OS version upgrades and monthly node OS updates. |
| 80 | +
|
| 81 | +You can stay up to date with the availability of new monthly releases using the [AKS release tracker][aks-release-tracker] and [AKS release notes][aks-release-notes]. |
| 82 | + |
| 83 | +### Windows node OS version upgrades |
| 84 | + |
| 85 | +Windows has a release cadence for new versions of the OS, including Windows Server 2019 and Windows Server 2022. When upgrading your Windows node OS version, ensure the Windows container image version matches the Windows container host version and the node pools have only one version of Windows Server. |
| 86 | + |
| 87 | +To upgrade the Windows node OS version, you need to complete the following steps: |
| 88 | + |
| 89 | +1. Create a new node pool with the new Windows Server version. |
| 90 | +2. Deploy your workloads with the new Windows container images to the new node pool. |
| 91 | +3. Decommission the old node pool. |
| 92 | + |
| 93 | +For more information, see [Upgrade Windows Server workloads on AKS][upgrade-windows-workloads-aks]. |
| 94 | + |
| 95 | +> [!NOTE] |
| 96 | +> Windows announced a new [Windows Server Annual Channel for Containers](https://techcommunity.microsoft.com/t5/windows-server-news-and-best/windows-server-annual-channel-for-containers/ba-p/3866248) that supports portability and mixed versions of Windows nodes and containers. This feature isn't yet supported in AKS. |
| 97 | +> |
| 98 | +> To track AKS feature plans, see the [Public AKS roadmap](https://github.com/Azure/AKS/projects/1#card-90806240). |
| 99 | +
|
| 100 | +## Next steps |
| 101 | + |
| 102 | +To learn more about Windows containers on AKS, see the following resources: |
| 103 | + |
| 104 | +* [Learn how to deploy, manage, and monitor Windows containers on AKS](/training/paths/deploy-manage-monitor-wincontainers-aks). |
| 105 | +* Open an issue or provide feedback in the [Windows containers GitHub repository](https://github.com/microsoft/Windows-Containers/issues). |
| 106 | +* Review the [third-party partner solutions for Windows on AKS][windows-on-aks-partner-solutions]. |
| 107 | + |
| 108 | +<!-- LINKS - internal --> |
| 109 | +[azure-cni-overlay]: ./azure-cni-overlay.md |
| 110 | +[azure-cni-dynamic-ip-allocation]: ./configure-azure-cni-dynamic-ip-allocation.md |
| 111 | +[azure-cni-choose-network-model]: ./azure-cni-overlay.md#choosing-a-network-model-to-use |
| 112 | +[network-concepts-for-aks-applications]: ./concepts-network.md |
| 113 | +[windows-vs-linux]: ./windows-vs-linux-containers.md |
| 114 | +[azurenpm-vs-calico]: ./use-network-policies.md#differences-between-azure-network-policy-manager-and-calico-network-policy-and-their-capabilities |
| 115 | +[network-policies-aks]: ./use-network-policies.md |
| 116 | +[dsr]: ../load-balancer/load-balancer-multivip-overview.md#rule-type-2-backend-port-reuse-by-using-floating-ip |
| 117 | +[upgrade-aks-cluster]: ./upgrade-cluster.md |
| 118 | +[upgrade-aks-node-images]: ./node-image-upgrade.md |
| 119 | +[upgrade-windows-workloads-aks]: ./upgrade-windows-2019-2022.md |
| 120 | +[windows-on-aks-partner-solutions]: ./windows-aks-partner-solutions.md |
| 121 | + |
| 122 | +<!-- LINKS - external --> |
| 123 | +[aks-release-notes]: https://github.com/Azure/AKS/releases |
| 124 | +[aks-release-tracker]: https://releases.aks.azure.com/ |
0 commit comments