Gallery › Kubernetes › Azure built-in policies
Azure Arc enabled Kubernetes clusters should have the Azure Policy extension installed
Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.1.0
The Azure Policy extension for Azure Arc provides at-scale enforcements and safeguards on your Arc enabled Kubernetes clusters in a centralized, consistent manner. Learn more at https://aka.ms/akspolicydoc.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONArcPolicyExtension_Audit.json · 65 lines
{
"properties": {
"displayName": "Azure Arc enabled Kubernetes clusters should have the Azure Policy extension installed",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "The Azure Policy extension for Azure Arc provides at-scale enforcements and safeguards on your Arc enabled Kubernetes clusters in a centralized, consistent manner. Learn more at https://aka.ms/akspolicydoc.",
"metadata": {
"version": "1.1.0",
"category": "Kubernetes"
},
"version": "1.1.0",
"parameters": {
"effect": {
"type": "String",
"defaultValue": "AuditIfNotExists",
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Kubernetes/connectedClusters"
},
{
"field": "Microsoft.Kubernetes/connectedClusters/distribution",
"notEquals": "aks"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.KubernetesConfiguration/extensions",
"evaluationDelay": "AfterProvisioning",
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.KubernetesConfiguration/extensions/extensionType",
"equals": "microsoft.policyinsights"
},
{
"field": "Microsoft.KubernetesConfiguration/extensions/provisioningState",
"equals": "Succeeded"
}
]
}
}
}
},
"versions": [
"1.1.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/6b2122c1-8120-4ff5-801b-17625a355590",
"name": "6b2122c1-8120-4ff5-801b-17625a355590"
}Bylaw6b2122c1-8120-4ff5-801b-17625a355590.bylaw.ps1 · 33 lines
# Converted from ArcPolicyExtension_Audit.json by ConvertTo-Bylaw.
Policy '6b2122c1-8120-4ff5-801b-17625a355590' {
Properties @{
DisplayName = 'Azure Arc enabled Kubernetes clusters should have the Azure Policy extension installed'
Description = 'The Azure Policy extension for Azure Arc provides at-scale enforcements and safeguards on your Arc enabled Kubernetes clusters in a centralized, consistent manner. Learn more at https://aka.ms/akspolicydoc.'
Version = '1.1.0'
Category = 'Kubernetes'
PolicyVersion = '1.1.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Kubernetes/connectedClusters' {
Require 'distribution is aks' {
Field distribution | Must -Be 'aks'
}
}
AuditIfNotExists 'Microsoft.KubernetesConfiguration/extensions' -EvaluationDelay AfterProvisioning -Effect (Param Effect) {
Require 'extensionType is microsoft.policyinsights and provisioningState is Succeeded' {
Field extensionType | Must -Be 'microsoft.policyinsights'
Field provisioningState | Must -Be 'Succeeded'
}
}
}Source: built-in-policies/policyDefinitions/Kubernetes/ArcPolicyExtension_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw