Pod sandboxing with Azure Kubernetes Service (AKS)

Pod sandboxing on AKS uses Kata Containers to run each sandboxed pod in a lightweight virtual machine (VM) with its own guest kernel. This compute boundary isolates the workload from the host kernel and workloads in other pod VMs. To learn about the architecture, benefits, and use cases, see Overview of Pod sandboxing in Azure Kubernetes Service (AKS).

In this article, you deploy Pod sandboxing on a new or existing Azure Linux AKS cluster, deploy an application with the Kata runtime, and optionally verify kernel isolation.

For clusters that use node auto-provisioning (NAP), follow Use Pod sandboxing with node auto-provisioning instead of the Azure CLI node pool creation steps.

Deploying Pod sandboxing by using Kata Containers is similar to the standard runc workflow to deploy containers. Clusters with Pod sandboxing enabled come with a specific runtime class that you can reference in a pod manifest, runtimeClassName: kata-vm-isolation (GA). For more information about runtime class defaults and customization, see Considerations for Pod sandboxing.

Limitations

The following constraints apply to Pod sandboxing with kata-vm-isolation:

  • Kata containers might not reach the IOPS performance limits that traditional containers can reach on Azure Files and high-performance local SSD.
  • [Microsoft Defender for Containers][defender-for-containers] doesn't support assessing Kata runtime pods.
  • Kata host-network access isn't supported. You can't directly access host networking configuration from within the pod VM.
  • CPU and memory allocation differs from runc. Each Kata pod runs in a pod VM whose size comes from pod limits:
  • Pod sandboxing is supported only on Azure Linux. Ubuntu, Windows, and Azure Container Linux aren't supported. For more information, see Azure Linux container host for AKS.
  • You can't enable Federal Information Processing Standard (FIPS) or Trusted Launch on a node pool that uses Pod sandboxing.
  • Arm64 architecture isn't supported on a node pool that uses Pod sandboxing.

Prerequisites

  • The Azure CLI version 2.80.0 or later. Run az --version to find the version of your Azure CLI, and run az upgrade to upgrade. For more details, see the steps at Install Azure CLI.
  • AKS supports Pod sandboxing on Kubernetes version 1.27.0 and higher. NAP-provisioned Pod sandboxing nodes require Kubernetes version 1.32 or later and Azure Linux 3.
  • To manage a Kubernetes cluster, use the Kubernetes command-line client kubectl. Azure Cloud Shell comes with kubectl. You can install kubectl locally using the az aks install-cli command.

Create a cluster with Pod sandboxing

Perform the following steps to deploy an Azure Linux AKS cluster using the Azure CLI.

  1. Create an AKS cluster by running the az aks create command with the following parameters:

    Parameter Required value Notes
    --workload-runtime KataVmIsolation Enables Pod sandboxing on the node pool.
    --os-sku AzureLinux Pod sandboxing supports only the Azure Linux OS SKU.
    --node-vm-size A generation 2 VM size that supports nested virtualization For example, use a [Dsv3-series][dv3-series] VM size.
    --node-count 3 Creates three nodes for this example. Adjust the value for your workload.

    The following example creates a cluster named myAKSCluster with three nodes in myResourceGroup:

    az aks create \
        --name myAKSCluster \
        --resource-group myResourceGroup \
        --os-sku AzureLinux \
        --workload-runtime KataVmIsolation \
        --node-vm-size Standard_D4s_v3 \
        --node-count 3 \
        --generate-ssh-keys
    
  2. Run the following command to get access credentials for the Kubernetes cluster. Use the az aks get-credentials command and replace the values for the cluster name and the resource group name.

    az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
    
  3. List all Pods in all namespaces by running the kubectl get pods command.

    kubectl get pods --all-namespaces
    

Enable Pod sandboxing on an existing cluster

To use this feature with an existing AKS cluster, the following requirements must be met:

  • The cluster runs Kubernetes version 1.27.0 or higher.

  • Use the following command to enable Pod sandboxing by creating a node pool to host it.

  1. Add a node pool to your AKS cluster by using the az aks nodepool add command with the following parameters:

    Parameter Required value Notes
    --resource-group The resource group that contains the existing AKS cluster For example, use myResourceGroup.
    --cluster-name The name of the existing AKS cluster For example, use myAKSCluster.
    --name A unique node pool name For example, use nodepool2.
    --workload-runtime KataVmIsolation Enables Pod sandboxing on the node pool.
    --os-sku AzureLinux Pod sandboxing supports only the Azure Linux OS SKU.
    --node-vm-size A generation 2 VM size that supports nested virtualization For example, use a [Dsv3-series][dv3-series] VM size.
    --node-count 1 Creates one node for this example. Adjust the value for your workload.

    The following example adds a node pool to myAKSCluster with one node in nodepool2 in the myResourceGroup:

    az aks nodepool add --cluster-name myAKSCluster --resource-group myResourceGroup --name nodepool2 --os-sku AzureLinux --workload-runtime KataVmIsolation --node-vm-size Standard_D4s_v3 --node-count 1
    
  2. Verify that the node pool was added successfully and that the Pod sandboxing node pool uses the expected workload runtime, OS SKU, and VM size.

    az aks show \
        --name myAKSCluster \
        --resource-group myResourceGroup \
        --query provisioningState \
        --output tsv
    
    az aks nodepool show \
        --cluster-name myAKSCluster \
        --resource-group myResourceGroup \
        --name nodepool2 \
        --query "{workloadRuntime:workloadRuntime, osSku:osSku, vmSize:vmSize}" \
        --output table
    

    The cluster provisioning state should be Succeeded. The node pool output should show KataVmIsolation, AzureLinux, and the VM size you selected.