AKS network policies are not configured

Apply network policies in AKS to allow only required pod traffic.

Description

Restricting AKS Pod traffic requires a supported policy engine and a NetworkPolicy that selects the Pods and the traffic direction to restrict.

Potential impact

Without an applicable policy, Pods may accept or initiate unnecessary connections unless another control blocks them.

Remediation

Enable an engine compatible with the cluster network, then deploy rules that allow required services and DNS. Test connections to a selected Pod for ingress and from it for egress. Verify permitted and blocked traffic in each direction the policy covers.

Examples

The second Bicep excerpt selects Azure CNI and Azure NPM for two Linux nodes. Supply a supported Kubernetes version and VM size. Microsoft recommends Azure CNI Powered by Cilium for new Linux deployments.

Before

bicep
param kubernetesVersion string
param nodeVmSize string

resource aksCluster1 'Microsoft.ContainerService/managedClusters@2020-02-01' = {
  name: 'aksCluster1'
  location: resourceGroup().location
  properties: {
    kubernetesVersion: kubernetesVersion
    dnsPrefix: 'dnsprefix'
    agentPoolProfiles: [
      {
        name: 'agentpool'
        count: 2
        vmSize: nodeVmSize
        osType: 'Linux'
      }
    ]
  }
}

After

bicep
param kubernetesVersion string
param nodeVmSize string

resource aksCluster1 'Microsoft.ContainerService/managedClusters@2020-02-01' = {
  name: 'aksCluster1'
  location: resourceGroup().location
  properties: {
    kubernetesVersion: kubernetesVersion
    dnsPrefix: 'dnsprefix'
    agentPoolProfiles: [
      {
        name: 'agentpool'
        count: 2
        vmSize: nodeVmSize
        osType: 'Linux'
      }
    ]
    networkProfile: {
      networkPlugin: 'azure'
      networkPolicy: 'azure'
    }
  }
}

References