Gallery › Kubernetes › Azure built-in policies
Azure Kubernetes Service Clusters should enable Image Cleaner
Converted Policy Audit Disabled Mode Indexed Version 1.0.0
Image Cleaner performs automatic vulnerable, unused image identification and removal, which mitigates the risk of stale images and reduces the time required to clean them up. Learn more at: https://aka.ms/aks/image-cleaner.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONAKS_ImageCleaner_Audit.json · 58 lines
{
"properties": {
"policyType": "BuiltIn",
"displayName": "Azure Kubernetes Service Clusters should enable Image Cleaner",
"description": "Image Cleaner performs automatic vulnerable, unused image identification and removal, which mitigates the risk of stale images and reduces the time required to clean them up. Learn more at: https://aka.ms/aks/image-cleaner.",
"metadata": {
"version": "1.0.0",
"category": "Kubernetes"
},
"version": "1.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"
},
{
"anyOf": [
{
"field": "Microsoft.ContainerService/managedClusters/securityProfile.imageCleaner.enabled",
"exists": "false"
},
{
"field": "Microsoft.ContainerService/managedClusters/securityProfile.imageCleaner.enabled",
"equals": "false"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/af3c26b2-6fad-493e-9236-9c68928516ab",
"name": "af3c26b2-6fad-493e-9236-9c68928516ab"
}Bylawaf3c26b2-6fad-493e-9236-9c68928516ab.bylaw.ps1 · 33 lines
# Converted from AKS_ImageCleaner_Audit.json by ConvertTo-Bylaw.
Policy 'af3c26b2-6fad-493e-9236-9c68928516ab' {
Properties @{
DisplayName = 'Azure Kubernetes Service Clusters should enable Image Cleaner'
Description = 'Image Cleaner performs automatic vulnerable, unused image identification and removal, which mitigates the risk of stale images and reduces the time required to clean them up. Learn more at: https://aka.ms/aks/image-cleaner.'
Version = '1.0.0'
Category = 'Kubernetes'
PolicyVersion = '1.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 'securityProfile.imageCleaner.enabled exists' {
Field securityProfile.imageCleaner.enabled | Must -Exist
}
Require 'securityProfile.imageCleaner.enabled is not false' {
Field securityProfile.imageCleaner.enabled | Must -Not -Be 'false' -IfPresent
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Kubernetes/AKS_ImageCleaner_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw