Bylaw

Gallery › Kubernetes › Azure built-in policies

Azure Kubernetes Service Private Clusters should be enabled

Converted Policy Audit Disabled Mode Indexed Version 2.0.0

Enable the private cluster feature for your Azure Kubernetes Service cluster to ensure network traffic between your API server and your node pools remains on the private network only. This is a common requirement in many regulatory and industry compliance standards.

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONAKS_PrivateCluster_Deny.json · 51 lines
{
  "properties": {
    "policyType": "BuiltIn",
    "displayName": "Azure Kubernetes Service Private Clusters should be enabled",
    "description": "Enable the private cluster feature for your Azure Kubernetes Service cluster to ensure network traffic between your API server and your node pools remains on the private network only. This is a common requirement in many regulatory and industry compliance standards.",
    "metadata": {
      "version": "2.0.0",
      "category": "Kubernetes"
    },
    "version": "2.0.0",
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "type": "String",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy.",
          "portalReview": true
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.ContainerService/managedClusters"
          },
          {
            "field": "Microsoft.ContainerService/managedClusters/apiServerAccessProfile.enablePrivateCluster",
            "notEquals": true
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "2.0.0",
      "1.0.1"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/040732e8-d947-40b8-95d6-854c95024bf8",
  "name": "040732e8-d947-40b8-95d6-854c95024bf8"
}
Bylaw040732e8-d947-40b8-95d6-854c95024bf8.bylaw.ps1 · 29 lines
# Converted from AKS_PrivateCluster_Deny.json by ConvertTo-Bylaw.
Policy '040732e8-d947-40b8-95d6-854c95024bf8' {

    Properties @{
        DisplayName   = 'Azure Kubernetes Service Private Clusters should be enabled'
        Description   = 'Enable the private cluster feature for your Azure Kubernetes Service cluster to ensure network traffic between your API server and your node pools remains on the private network only. This is a common requirement in many regulatory and industry compliance standards.'
        Version       = '2.0.0'
        Category      = 'Kubernetes'
        PolicyVersion = '2.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy.'
        Metadata      = [ordered]@{ portalReview = $true }
    }

    Resource 'Microsoft.ContainerService/managedClusters' {

        Require 'apiServerAccessProfile.enablePrivateCluster is true' {
            Field apiServerAccessProfile.enablePrivateCluster | Must -Be $true
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Kubernetes/AKS_PrivateCluster_Deny.json in Azure/azure-policy, under the MIT licence.