Gallery › Kubernetes › Azure Community Policy
Ensure ephemeral disks are used for OS disks on Agent Pool Profiles
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
Ephemeral OS disks are created on the local virtual machine (VM) storage and not saved to the remote Azure Storage, as when using managed OS disks.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 45 lines
{
"name": "2dec5f47-bc40-40d1-8c7d-a39d9d6808d2",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Ensure ephemeral disks are used for OS disks on Agent Pool Profiles",
"description": "Ephemeral OS disks are created on the local virtual machine (VM) storage and not saved to the remote Azure Storage, as when using managed OS disks.",
"metadata": {
"version": "1.0.0",
"category": "Kubernetes"
},
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.ContainerService/managedClusters"
},
{
"field": "Microsoft.ContainerService/managedClusters/agentPoolProfiles[*].osDiskType",
"notequals": "Ephemeral"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw2dec5f47-bc40-40d1-8c7d-a39d9d6808d2.bylaw.ps1 · 29 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '2dec5f47-bc40-40d1-8c7d-a39d9d6808d2' {
Properties @{
DisplayName = 'Ensure ephemeral disks are used for OS disks on Agent Pool Profiles'
Description = 'Ephemeral OS disks are created on the local virtual machine (VM) storage and not saved to the remote Azure Storage, as when using managed OS disks.'
Version = '1.0.0'
Category = 'Kubernetes'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.ContainerService/managedClusters' {
Require 'agentPoolProfiles and osDiskType are as required' {
Count 'agentPoolProfiles[*]' -Where {
Field osDiskType | Must -Be 'Ephemeral'
} | Must -Not -Be 0
}
}
Effect (Param Effect)
}Source: policyDefinitions/Kubernetes/ensure-ephemeral-disks-are-used-for-os-disks-on-agent-pool-profiles/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw