Gallery › Kubernetes › Azure built-in policies
Kubernetes cluster pod security restricted standards for Linux-based workloads
Converted Initiative Version 2.5.0
This initiative includes the policies for the Kubernetes cluster pod security restricted standards. This policy is generally available for Kubernetes Service (AKS), and preview for Azure Arc enabled Kubernetes. For instructions on using this policy, visit https://aka.ms/kubepolicydoc.
ConvertTo-Bylaw converted this initiative, and proved that the file compiles back to the same definition.
Azure Policy JSONPSPRestrictedStandard.json · 298 lines
{
"properties": {
"displayName": "Kubernetes cluster pod security restricted standards for Linux-based workloads",
"policyType": "BuiltIn",
"description": "This initiative includes the policies for the Kubernetes cluster pod security restricted standards. This policy is generally available for Kubernetes Service (AKS), and preview for Azure Arc enabled Kubernetes. For instructions on using this policy, visit https://aka.ms/kubepolicydoc.",
"metadata": {
"version": "2.5.0",
"category": "Kubernetes"
},
"version": "2.5.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "'Audit' allows a non-compliant resource to be created or updated, but flags it as non-compliant. 'Deny' blocks the non-compliant resource creation or update. 'Disabled' turns off the policy."
},
"allowedValues": [
"audit",
"Audit",
"deny",
"Deny",
"disabled",
"Disabled"
],
"defaultValue": "Audit"
},
"excludedNamespaces": {
"type": "Array",
"metadata": {
"displayName": "Namespace exclusions",
"description": "List of Kubernetes namespaces to exclude from policy evaluation."
},
"defaultValue": [
"kube-system",
"gatekeeper-system",
"azure-arc",
"azure-extensions-usage-system"
]
},
"namespaces": {
"type": "Array",
"metadata": {
"displayName": "Namespace inclusions",
"description": "List of Kubernetes namespaces to only include in policy evaluation. An empty list means the policy is applied to all resources in all namespaces."
},
"defaultValue": []
},
"allowedCapabilities": {
"type": "Array",
"metadata": {
"displayName": "Allowed add capabilities",
"description": "The list of capabilities that are allowed to be added to a container."
},
"defaultValue": [
"CHOWN",
"DAC_OVERRIDE",
"FSETID",
"FOWNER",
"MKNOD",
"NET_RAW",
"SETGID",
"SETUID",
"SETFCAP",
"SETPCAP",
"NET_BIND_SERVICE",
"SYS_CHROOT",
"KILL",
"AUDIT_WRITE"
]
},
"requiredDropCapabilities": {
"type": "Array",
"metadata": {
"displayName": "Required drop capabilities",
"description": "The list of capabilities that must be dropped by a container."
},
"defaultValue": []
}
},
"policyDefinitions": [
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/95edb821-ddaf-4404-9732-666045e056b4",
"definitionVersion": "9.*.*",
"policyDefinitionReferenceId": "NoPrivilegedContainers",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"excludedNamespaces": {
"value": "[parameters('excludedNamespaces')]"
},
"namespaces": {
"value": "[parameters('namespaces')]"
}
}
},
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/1c6e92c9-99f0-4e55-9cf2-0c234dc48f99",
"definitionVersion": "7.*.*",
"policyDefinitionReferenceId": "NoPrivilegeEscalation",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"excludedNamespaces": {
"value": "[parameters('excludedNamespaces')]"
},
"namespaces": {
"value": "[parameters('namespaces')]"
}
}
},
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/82985f06-dc18-4a48-bc1c-b9f4f0098cfe",
"definitionVersion": "6.*.*",
"policyDefinitionReferenceId": "BlockUsingHostNetwork",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"excludedNamespaces": {
"value": "[parameters('excludedNamespaces')]"
},
"namespaces": {
"value": "[parameters('namespaces')]"
},
"allowHostNetwork": {
"value": false
},
"minPort": {
"value": 0
},
"maxPort": {
"value": 0
}
}
},
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/47a1ee2f-2a2a-4576-bf2a-e0e36709c2b8",
"definitionVersion": "5.*.*",
"policyDefinitionReferenceId": "BlockUsingHostProcessIDAndIPC",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"excludedNamespaces": {
"value": "[parameters('excludedNamespaces')]"
},
"namespaces": {
"value": "[parameters('namespaces')]"
}
}
},
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/c26596ff-4d70-4e6a-9a30-c2506bd2f80c",
"definitionVersion": "6.*.*",
"policyDefinitionReferenceId": "ContainerCapabilities",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"excludedNamespaces": {
"value": "[parameters('excludedNamespaces')]"
},
"namespaces": {
"value": "[parameters('namespaces')]"
},
"allowedCapabilities": {
"value": "[parameters('allowedCapabilities')]"
},
"requiredDropCapabilities": {
"value": "[parameters('requiredDropCapabilities')]"
}
}
},
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/16697877-1118-4fb1-9b65-9898ec2509ec",
"definitionVersion": "5.*.*",
"policyDefinitionReferenceId": "AllowedVolumeTypes",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"excludedNamespaces": {
"value": "[parameters('excludedNamespaces')]"
},
"namespaces": {
"value": "[parameters('namespaces')]"
},
"allowedVolumeTypes": {
"value": [
"configMap",
"csi",
"downwardAPI",
"emptyDir",
"ephemeral",
"persistentVolumeClaim",
"projected",
"secret"
]
}
}
},
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/f06ddb64-5fa3-4b77-b166-acb36f7f6042",
"definitionVersion": "6.*.*",
"policyDefinitionReferenceId": "AllowedUsersGroups",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"excludedNamespaces": {
"value": "[parameters('excludedNamespaces')]"
},
"namespaces": {
"value": "[parameters('namespaces')]"
},
"runAsUserRule": {
"value": "MustRunAsNonRoot"
},
"runAsUserRanges": {
"value": {
"ranges": []
}
},
"runAsGroupRule": {
"value": "MustRunAs"
},
"runAsGroupRanges": {
"value": {
"ranges": [
{
"min": 1,
"max": 65535
}
]
}
},
"supplementalGroupsRule": {
"value": "MustRunAs"
},
"supplementalGroupsRanges": {
"value": {
"ranges": [
{
"min": 1,
"max": 65535
}
]
}
},
"fsGroupRule": {
"value": "MustRunAs"
},
"fsGroupRanges": {
"value": {
"ranges": [
{
"min": 1,
"max": 65535
}
]
}
}
}
},
{
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/975ce327-682c-4f2e-aa46-b9598289b86c",
"definitionVersion": "7.*.*",
"policyDefinitionReferenceId": "AllowedSeccompProfiles",
"parameters": {
"effect": {
"value": "[parameters('effect')]"
},
"excludedNamespaces": {
"value": "[parameters('excludedNamespaces')]"
},
"namespaces": {
"value": "[parameters('namespaces')]"
},
"allowedProfiles": {
"value": [
"runtime/default",
"docker/default"
]
}
}
}
],
"versions": [
"2.5.0",
"2.4.0"
]
},
"id": "/providers/Microsoft.Authorization/policySetDefinitions/42b8ef37-b724-4e24-bbc8-7a7708edfe00",
"name": "42b8ef37-b724-4e24-bbc8-7a7708edfe00"
}Bylaw42b8ef37-b724-4e24-bbc8-7a7708edfe00.bylaw.ps1 · 145 lines
# Converted from PSPRestrictedStandard.json by ConvertTo-Bylaw.
Initiative '42b8ef37-b724-4e24-bbc8-7a7708edfe00' {
Properties @{
DisplayName = 'Kubernetes cluster pod security restricted standards for Linux-based workloads'
Description = 'This initiative includes the policies for the Kubernetes cluster pod security restricted standards. This policy is generally available for Kubernetes Service (AKS), and preview for Azure Arc enabled Kubernetes. For instructions on using this policy, visit https://aka.ms/kubepolicydoc.'
Version = '2.5.0'
Category = 'Kubernetes'
PolicyVersion = '2.5.0'
}
Parameter Effect @{
AllowedValues = @('audit', 'Audit', 'deny', 'Deny', 'disabled', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = '''Audit'' allows a non-compliant resource to be created or updated, but flags it as non-compliant. ''Deny'' blocks the non-compliant resource creation or update. ''Disabled'' turns off the policy.'
}
Parameter ExcludedNamespaces @{
Type = 'Array'
Default = @('kube-system', 'gatekeeper-system', 'azure-arc', 'azure-extensions-usage-system')
DisplayName = 'Namespace exclusions'
Description = 'List of Kubernetes namespaces to exclude from policy evaluation.'
}
Parameter Namespaces @{
Type = 'Array'
Default = @()
DisplayName = 'Namespace inclusions'
Description = 'List of Kubernetes namespaces to only include in policy evaluation. An empty list means the policy is applied to all resources in all namespaces.'
}
Parameter AllowedCapabilities @{
Type = 'Array'
Default = @('CHOWN', 'DAC_OVERRIDE', 'FSETID', 'FOWNER', 'MKNOD', 'NET_RAW', 'SETGID', 'SETUID', 'SETFCAP', 'SETPCAP', 'NET_BIND_SERVICE', 'SYS_CHROOT', 'KILL', 'AUDIT_WRITE')
DisplayName = 'Allowed add capabilities'
Description = 'The list of capabilities that are allowed to be added to a container.'
}
Parameter RequiredDropCapabilities @{
Type = 'Array'
Default = @()
DisplayName = 'Required drop capabilities'
Description = 'The list of capabilities that must be dropped by a container.'
}
PolicyDefinition @{
Id = '95edb821-ddaf-4404-9732-666045e056b4'
ReferenceId = 'NoPrivilegedContainers'
Version = '9.*.*'
Parameters = [ordered]@{
effect = (Param Effect)
excludedNamespaces = (Param ExcludedNamespaces)
namespaces = (Param Namespaces)
}
}
PolicyDefinition @{
Id = '1c6e92c9-99f0-4e55-9cf2-0c234dc48f99'
ReferenceId = 'NoPrivilegeEscalation'
Version = '7.*.*'
Parameters = [ordered]@{
effect = (Param Effect)
excludedNamespaces = (Param ExcludedNamespaces)
namespaces = (Param Namespaces)
}
}
PolicyDefinition @{
Id = '82985f06-dc18-4a48-bc1c-b9f4f0098cfe'
ReferenceId = 'BlockUsingHostNetwork'
Version = '6.*.*'
Parameters = [ordered]@{
effect = (Param Effect)
excludedNamespaces = (Param ExcludedNamespaces)
namespaces = (Param Namespaces)
allowHostNetwork = $false
minPort = 0
maxPort = 0
}
}
PolicyDefinition @{
Id = '47a1ee2f-2a2a-4576-bf2a-e0e36709c2b8'
ReferenceId = 'BlockUsingHostProcessIDAndIPC'
Version = '5.*.*'
Parameters = [ordered]@{
effect = (Param Effect)
excludedNamespaces = (Param ExcludedNamespaces)
namespaces = (Param Namespaces)
}
}
PolicyDefinition @{
Id = 'c26596ff-4d70-4e6a-9a30-c2506bd2f80c'
ReferenceId = 'ContainerCapabilities'
Version = '6.*.*'
Parameters = [ordered]@{
effect = (Param Effect)
excludedNamespaces = (Param ExcludedNamespaces)
namespaces = (Param Namespaces)
allowedCapabilities = (Param AllowedCapabilities)
requiredDropCapabilities = (Param RequiredDropCapabilities)
}
}
PolicyDefinition @{
Id = '16697877-1118-4fb1-9b65-9898ec2509ec'
ReferenceId = 'AllowedVolumeTypes'
Version = '5.*.*'
Parameters = [ordered]@{
effect = (Param Effect)
excludedNamespaces = (Param ExcludedNamespaces)
namespaces = (Param Namespaces)
allowedVolumeTypes = @('configMap', 'csi', 'downwardAPI', 'emptyDir', 'ephemeral', 'persistentVolumeClaim', 'projected', 'secret')
}
}
PolicyDefinition @{
Id = 'f06ddb64-5fa3-4b77-b166-acb36f7f6042'
ReferenceId = 'AllowedUsersGroups'
Version = '6.*.*'
Parameters = [ordered]@{
effect = (Param Effect)
excludedNamespaces = (Param ExcludedNamespaces)
namespaces = (Param Namespaces)
runAsUserRule = 'MustRunAsNonRoot'
runAsUserRanges = [ordered]@{ ranges = @() }
runAsGroupRule = 'MustRunAs'
runAsGroupRanges = [ordered]@{ ranges = @([ordered]@{ min = 1; max = 65535 }) }
supplementalGroupsRule = 'MustRunAs'
supplementalGroupsRanges = [ordered]@{ ranges = @([ordered]@{ min = 1; max = 65535 }) }
fsGroupRule = 'MustRunAs'
fsGroupRanges = [ordered]@{ ranges = @([ordered]@{ min = 1; max = 65535 }) }
}
}
PolicyDefinition @{
Id = '975ce327-682c-4f2e-aa46-b9598289b86c'
ReferenceId = 'AllowedSeccompProfiles'
Version = '7.*.*'
Parameters = [ordered]@{
effect = (Param Effect)
excludedNamespaces = (Param ExcludedNamespaces)
namespaces = (Param Namespaces)
allowedProfiles = @('runtime/default', 'docker/default')
}
}
}Members (8)
- Kubernetes cluster should not allow privileged containers
- Kubernetes clusters should not allow container privilege escalation
- [Preview]: Kubernetes cluster pods should only use approved host network and port list
- [Preview]: Kubernetes cluster containers should not share host namespaces
- Kubernetes cluster containers should only use allowed capabilities
- Kubernetes cluster pods should only use allowed volume types
- Kubernetes cluster pods and containers should only run with approved user and group IDs
- Kubernetes cluster containers should only use allowed seccomp profiles
Source: built-in-policies/policySetDefinitions/Kubernetes/PSPRestrictedStandard.json in Azure/azure-policy, under the MIT licence.
Bylaw