Bylaw

Gallery › Kubernetes › Azure built-in policies

Deployment safeguards should help guide developers towards AKS recommended best practices

Converted Initiative Version 3.1.0

A collection of Kubernetes best practices that are recommended by Azure Kubernetes Service (AKS). For the best experience, use deployment safeguards to assign this policy initiative: https://aka.ms/aks/deployment-safeguards. Azure Policy Add-On for AKS is a pre-requisite for applying these best practices to your clusters. For instructions on enabling the Azure Policy Add-On, go to aka.ms/akspolicydoc

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

Azure Policy JSONAKS_Safeguards.json · 1046 lines
{
  "properties": {
    "displayName": "Deployment safeguards should help guide developers towards AKS recommended best practices",
    "policyType": "BuiltIn",
    "description": "A collection of Kubernetes best practices that are recommended by Azure Kubernetes Service (AKS). For the best experience, use deployment safeguards to assign this policy initiative: https://aka.ms/aks/deployment-safeguards. Azure Policy Add-On for AKS is a pre-requisite for applying these best practices to your clusters. For instructions on enabling the Azure Policy Add-On, go to aka.ms/akspolicydoc",
    "metadata": {
      "version": "3.1.0",
      "category": "Kubernetes"
    },
    "version": "3.1.0",
    "parameters": {
      "source": {
        "type": "String",
        "metadata": {
          "displayName": "Source",
          "description": "The source k8s object for constraint evaluation. 'Original' means only evaluate against the specific GroupVersionKind specified in the policy definition. 'Generated' means only evaluate against k8s objects generated by Gatekeeper ExpansionTemplates. 'All' means evaluate against both the original object and any generated ones."
        },
        "defaultValue": "All",
        "allowedValues": [
          "All",
          "Generated",
          "Original"
        ]
      },
      "warn": {
        "type": "Boolean",
        "metadata": {
          "displayName": "Warn",
          "description": "Whether or not to return warnings back to the user in the kubectl cli"
        },
        "allowedValues": [
          true,
          false
        ],
        "defaultValue": false
      },
      "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",
          "Deny",
          "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"
        ]
      },
      "allowedUsers": {
        "type": "Array",
        "metadata": {
          "displayName": "Allowed Users",
          "description": "Users that are allowed by deployment safeguards to make changes on kubernetes object."
        }
      },
      "allowedGroups": {
        "type": "Array",
        "metadata": {
          "displayName": "Allowed Groups",
          "description": "Groups that are allowed by deployment safeguards to make changes on kubernetes object."
        }
      },
      "excludedContainers": {
        "type": "Array",
        "metadata": {
          "displayName": "Containers exclusions",
          "description": "The list of InitContainers and Containers to exclude from policy evaluation. The identify is the name of container. Use an empty list to apply this policy to all containers in all namespaces."
        },
        "defaultValue": []
      },
      "excludedImages": {
        "type": "Array",
        "metadata": {
          "displayName": "Image exclusions",
          "description": "The list of InitContainers and Containers to exclude from policy evaluation. The identifier is the image of container. Prefix-matching can be signified with `*`. For example: `myregistry.azurecr.io/istio:*`. It is recommended that users use the fully-qualified Docker image name (e.g. start with a domain name) in order to avoid unexpectedly exempting images from an untrusted repository."
        },
        "defaultValue": []
      },
      "labels": {
        "type": "Array",
        "metadata": {
          "displayName": "AKS Specific Labels",
          "description": "Reserved labels specific to AKS."
        }
      },
      "allowedContainerImagesRegex": {
        "type": "String",
        "metadata": {
          "displayName": "Allowed registry or registries regex",
          "description": "The RegEx rule used to match allowed container image field in a Kubernetes cluster. For example, to allow any Azure Container Registry image by matching partial path: ^[^\\/]+\\.azurecr\\.io\\/.+$ and for multiple registries: ^([^\\/]+\\.azurecr\\.io|registry\\.io)\\/.+$"
        }
      },
      "reservedTaints": {
        "type": "Array",
        "metadata": {
          "displayName": "Reserved Taints",
          "description": "Reserved taints specific to AKS"
        }
      },
      "requiredProbes": {
        "type": "Array",
        "metadata": {
          "displayName": "Required probes list",
          "description": "The list of probes that are required to be defined on a container. Kubernetes currently supports 'livenessProbe', 'readinessProbe', and 'startupProbe'.",
          "portalReview": true
        },
        "defaultValue": [
          "readinessProbe",
          "livenessProbe"
        ]
      },
      "effectForMutationPolicies": {
        "type": "String",
        "metadata": {
          "displayName": "Mutate Effect",
          "description": "'Mutate' modifies a non-compliant resource to be compliant when creating or updating. 'Disabled' turns off the policy."
        },
        "allowedValues": [
          "Mutate",
          "Disabled"
        ],
        "defaultValue": "Disabled"
      },
      "effectForWarnOnlyPolicies": {
        "type": "String",
        "metadata": {
          "displayName": "Print mutation annotations effect",
          "description": "'Audit' reports mutation annotations. 'Disabled' turns off mutation annotation reporting."
        },
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      },
      "messages": {
        "type": "Object",
        "metadata": {
          "displayName": "Map of mutations annotations and respective messages",
          "description": "The annotations are mapped to respective messages that will be printed upon resource mutation"
        },
        "defaultValue": {}
      },
      "allowedHostPorts": {
        "type": "Array",
        "metadata": {
          "displayName": "Allowed host ports list",
          "description": "The list of specific host ports that pods are allowed to use in the host network namespace. Can include individual ports (e.g., '80') or port ranges (e.g., '3000-5000'). Empty list means no host ports are allowed. Note that port 0 is not allowed according to Pod Security Standards.",
          "portalReview": true
        },
        "defaultValue": []
      },
      "allowedSysctls": {
        "type": "Array",
        "metadata": {
          "displayName": "Allowed sysctls",
          "description": "The list of plain sysctl names or sysctl patterns which end with *. The string * matches all sysctls. For more information, visit https://aka.ms/k8s-policy-sysctl-interfaces.",
          "portalReview": true
        },
        "defaultValue": [
          "kernel.shm_rmid_forced",
          "net.ipv4.ip_local_port_range",
          "net.ipv4.ip_unprivileged_port_start",
          "net.ipv4.tcp_syncookies",
          "net.ipv4.ping_group_range",
          "net.ipv4.ip_local_reserved_ports",
          "net.ipv4.tcp_keepalive_time",
          "net.ipv4.tcp_fin_timeout",
          "net.ipv4.tcp_keepalive_intvl",
          "net.ipv4.tcp_keepalive_probes"
        ]
      },
      "forcePrivilegeEscalationToBeFalse": {
        "type": "Boolean",
        "metadata": {
          "displayName": "Force all container securityContext.allowPrivilegeEscalation fields to be explicity set to false",
          "description": "If set to true, then `allowPrivilegeEscalation` must explicitly be set to false regardless of the `runAsUser` field in the container securityContext. Setting this value to true will make this policy follow the behavior of the Kubernetes Pod Security Standards for Privilege Escalation at the restricted level: https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted"
        },
        "defaultValue": false
      },
      "windowsAllowedHostPaths": {
        "type": "Object",
        "metadata": {
          "displayName": "Allowed host paths for windows containers",
          "description": "The host paths allowed for windows pod hostPath volumes to use. Provide an empty paths list to block all host paths. Use \"C:\\\" to allow all windows host paths.",
          "portalReview": true
        },
        "defaultValue": {
          "paths": []
        },
        "schema": {
          "type": "object",
          "properties": {
            "paths": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "pathPrefix": {
                    "type": "string"
                  },
                  "readOnly": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "pathPrefix",
                  "readOnly"
                ],
                "additionalProperties": false
              }
            }
          },
          "required": [
            "paths"
          ],
          "additionalProperties": false
        }
      },
      "allowedHostPaths": {
        "type": "Object",
        "metadata": {
          "displayName": "Allowed host paths",
          "description": "The host paths allowed for pod hostPath volumes to use. Provide an empty paths list to block all host paths.",
          "portalReview": true
        },
        "defaultValue": {
          "paths": []
        },
        "schema": {
          "type": "object",
          "properties": {
            "paths": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "pathPrefix": {
                    "type": "string"
                  },
                  "readOnly": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "pathPrefix",
                  "readOnly"
                ],
                "additionalProperties": false
              }
            }
          },
          "required": [
            "paths"
          ],
          "additionalProperties": false
        }
      },
      "allowedAppArmorProfiles": {
        "type": "Array",
        "metadata": {
          "displayName": "Allowed AppArmor profiles",
          "description": "The list of AppArmor profiles that containers are allowed to use. E.g. [ \"runtime/default\", \"docker/default\" ]. Use \"localhost/*\" to allow all localhost profiles. Provide empty list as input to block everything.",
          "portalReview": true
        },
        "defaultValue": [
          "runtime/default"
        ]
      },
      "allowedCapabilities": {
        "type": "Array",
        "metadata": {
          "displayName": "Allowed capabilities",
          "description": "The list of capabilities that are allowed to be added to a container. Provide empty list as input to block everything.",
          "portalReview": true
        },
        "defaultValue": []
      },
      "requiredDropCapabilities": {
        "type": "Array",
        "metadata": {
          "displayName": "Required drop capabilities",
          "description": "The list of capabilities that must be dropped by a container.",
          "portalReview": true
        },
        "defaultValue": []
      },
      "allowedSeccompProfiles": {
        "type": "Array",
        "metadata": {
          "displayName": "Allowed seccomp profiles",
          "description": "The list of seccomp profiles that containers are allowed to use. E.g. '`runtime/default`, `docker/default`, `unconfined` and/or `localhost/*`'. Provide empty list as input to block everything. Putting a `*` in this array allows all Profiles to be used.",
          "portalReview": true
        },
        "defaultValue": [
          "RuntimeDefault",
          "Localhost"
        ]
      },
      "runAsUserRule": {
        "type": "String",
        "metadata": {
          "displayName": "Run as user rule",
          "description": "The 'RunAsUser' rule that containers are allowed to run with. MustRunAs requires at least one range to be specified. MustRunAsNonRoot requires the pod be submitted with non-zero runAsUser or have USER directive defined (using a numeric UID) in the image. RunAsAny allows any runAsUser to be specified",
          "portalReview": true
        },
        "allowedValues": [
          "MustRunAs",
          "MustRunAsNonRoot",
          "RunAsAny"
        ],
        "defaultValue": "MustRunAsNonRoot"
      },
      "runAsUserRanges": {
        "type": "Object",
        "metadata": {
          "displayName": "Allowed user ID ranges",
          "description": "The user ID ranges that are allowed for containers to use. Set 'max' as '-1' to skip max limit evaluation. Empty array blocks every defined value for 'MustRunAs'.",
          "portalReview": true
        },
        "defaultValue": {
          "ranges": []
        },
        "schema": {
          "type": "object",
          "properties": {
            "ranges": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "min": {
                    "type": "integer"
                  },
                  "max": {
                    "type": "integer"
                  }
                },
                "required": [
                  "min",
                  "max"
                ],
                "additionalProperties": false
              }
            }
          },
          "required": [
            "ranges"
          ],
          "additionalProperties": false
        }
      },
      "allowedVolumeTypes": {
        "type": "Array",
        "metadata": {
          "displayName": "Allowed volume types",
          "description": "The list of volume types that can be used by a pod. Provide empty list as input to block everything.",
          "portalReview": true
        },
        "defaultValue": []
      }
    },
    "policyDefinitions": [
      {
        "policyDefinitionReferenceId": "restrictedNodeEditsInKubernetesCluster",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/53a4a537-990c-495a-92e0-7c21a465442c",
        "definitionVersion": "1.*.*",
        "parameters": {
          "warn": {
            "value": "[parameters('warn')]"
          },
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "allowedUsers": {
            "value": "[parameters('allowedUsers')]"
          },
          "allowedGroups": {
            "value": "[parameters('allowedGroups')]"
          },
          "source": {
            "value": "[parameters('source')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "containerResourceRequests",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/03a4ecdb-0684-4039-be91-2762979e1bc8",
        "definitionVersion": "1.*.*-preview",
        "parameters": {
          "warn": {
            "value": "[parameters('warn')]"
          },
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "excludedImages": {
            "value": "[parameters('excludedImages')]"
          },
          "source": {
            "value": "[parameters('source')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "podEnforceAntiaffinityInKubernetesCluster",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/34c88cd4-5d72-4dbb-bf77-12c3cafe8791",
        "definitionVersion": "1.*.*",
        "parameters": {
          "warn": {
            "value": "[parameters('warn')]"
          },
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "restrictedLabelsInKubernetesCluster",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/a22123bd-b9da-4c86-9424-24903e91fd55",
        "definitionVersion": "1.*.*",
        "parameters": {
          "warn": {
            "value": "[parameters('warn')]"
          },
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "allowedUsers": {
            "value": "[parameters('allowedUsers')]"
          },
          "allowedGroups": {
            "value": "[parameters('allowedGroups')]"
          },
          "labels": {
            "value": "[parameters('labels')]"
          },
          "source": {
            "value": "[parameters('source')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "ensureAllowedContainerImagesInKubernetesCluster",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/febd0533-8e55-448f-b837-bd0e06f16469",
        "definitionVersion": "9.*.*",
        "parameters": {
          "warn": {
            "value": "[parameters('warn')]"
          },
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "allowedContainerImagesRegex": {
            "value": "[parameters('allowedContainerImagesRegex')]"
          },
          "excludedContainers": {
            "value": "[parameters('excludedContainers')]"
          },
          "source": {
            "value": "[parameters('source')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "restrictedTaintsInKubernetesCluster",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/48940d92-ff05-449e-9111-e742d9280451",
        "definitionVersion": "1.*.*",
        "parameters": {
          "warn": {
            "value": "[parameters('warn')]"
          },
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "reservedTaints": {
            "value": "[parameters('reservedTaints')]"
          },
          "source": {
            "value": "[parameters('source')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "ensureProbesConfiguredInKubernetesCluster",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/b1a9997f-2883-4f12-bdff-2280f99b5915",
        "definitionVersion": "3.*.*",
        "parameters": {
          "warn": {
            "value": "[parameters('warn')]"
          },
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "requiredProbes": {
            "value": "[parameters('requiredProbes')]"
          },
          "excludedContainers": {
            "value": "[parameters('excludedContainers')]"
          },
          "excludedImages": {
            "value": "[parameters('excludedImages')]"
          },
          "source": {
            "value": "[parameters('source')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "ensureCsiDriverStorageClass",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/4f3823b6-6dac-4b5a-9c61-ce1afb829f17",
        "definitionVersion": "2.*.*",
        "parameters": {
          "warn": {
            "value": "[parameters('warn')]"
          },
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "uniqueServiceSelectors",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/b0fdedee-7b9e-4a17-9f5d-5e8e912d2f01",
        "definitionVersion": "1.*.*",
        "parameters": {
          "warn": {
            "value": "[parameters('warn')]"
          },
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "imagesDoNotUseLatest",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/021f8078-41a0-40e6-81b6-c6597da9f3ee",
        "definitionVersion": "2.*.*",
        "parameters": {
          "warn": {
            "value": "[parameters('warn')]"
          },
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "mutateReservedSystemPoolTaints",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/e16d171b-bfe5-4d79-a525-19736b396e92",
        "definitionVersion": "1.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effectForMutationPolicies')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "printMutationsAnnotations",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/e24df237-32cb-4a6c-a2f6-85b499cda9f2",
        "definitionVersion": "1.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effectForWarnOnlyPolicies')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "messages": {
            "value": "[parameters('messages')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "blockHostNamespaces",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/47a1ee2f-2a2a-4576-bf2a-e0e36709c2b8",
        "definitionVersion": "6.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "hostNetworkPorts",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/82985f06-dc18-4a48-bc1c-b9f4f0098cfe",
        "definitionVersion": "7.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          },
          "allowedHostPorts": {
            "value": "[parameters('allowedHostPorts')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "allowedSysctls",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/5e5a0673-649e-4d50-bf9d-5a387a4e2081",
        "definitionVersion": "1.*.*-preview",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          },
          "allowedSysctls": {
            "value": "[parameters('allowedSysctls')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "allowedUsersGroups",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/f06ddb64-5fa3-4b77-b166-acb36f7f6042",
        "definitionVersion": "6.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          },
          "excludedImages": {
            "value": "[parameters('excludedImages')]"
          },
          "excludedContainers": {
            "value": "[parameters('excludedContainers')]"
          },
          "runAsUserRule": {
            "value": "[parameters('runAsUserRule')]"
          },
          "runAsUserRanges": {
            "value": "[parameters('runAsUserRanges')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "windowsBlockContainerAdmin",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/5485eac0-7e8f-4964-998b-a44f4f0c1e75",
        "definitionVersion": "1.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          },
          "excludedImages": {
            "value": "[parameters('excludedImages')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "containerNoPrivilegeEscalation",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/1c6e92c9-99f0-4e55-9cf2-0c234dc48f99",
        "definitionVersion": "8.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          },
          "excludedImages": {
            "value": "[parameters('excludedImages')]"
          },
          "excludedContainers": {
            "value": "[parameters('excludedContainers')]"
          },
          "forcePrivilegeEscalationToBeFalse": {
            "value": "[parameters('forcePrivilegeEscalationToBeFalse')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "allowedHostPaths",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/098fc59e-46c7-4d99-9b16-64990e543d75",
        "definitionVersion": "6.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          },
          "excludedImages": {
            "value": "[parameters('excludedImages')]"
          },
          "excludedContainers": {
            "value": "[parameters('excludedContainers')]"
          },
          "allowedHostPaths": {
            "value": "[parameters('allowedHostPaths')]"
          },
          "windowsAllowedHostPaths": {
            "value": "[parameters('windowsAllowedHostPaths')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "enforceAppArmorProfile",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/511f5417-5d12-434d-ab2e-816901e72a5e",
        "definitionVersion": "6.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          },
          "excludedImages": {
            "value": "[parameters('excludedImages')]"
          },
          "excludedContainers": {
            "value": "[parameters('excludedContainers')]"
          },
          "allowedProfiles": {
            "value": "[parameters('allowedAppArmorProfiles')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "enforceSELinux",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/e1e6c427-07d9-46ab-9689-bfa85431e636",
        "definitionVersion": "8.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          },
          "excludedImages": {
            "value": "[parameters('excludedImages')]"
          },
          "enforcePSS": {
            "value": true
          }
        }
      },
      {
        "policyDefinitionReferenceId": "windowsBlockHostProcess",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/077f0ce1-86d6-4058-bc60-de05067e8622",
        "definitionVersion": "1.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          },
          "excludedImages": {
            "value": "[parameters('excludedImages')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "privilegedContainers",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/95edb821-ddaf-4404-9732-666045e056b4",
        "definitionVersion": "9.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          },
          "excludedImages": {
            "value": "[parameters('excludedImages')]"
          },
          "excludedContainers": {
            "value": "[parameters('excludedContainers')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "allowedProcMountType",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/f85eb0dd-92ee-40e9-8a76-db25a507d6d3",
        "definitionVersion": "8.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          },
          "excludedImages": {
            "value": "[parameters('excludedImages')]"
          },
          "excludedContainers": {
            "value": "[parameters('excludedContainers')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "containerAllowedCapabilities",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/c26596ff-4d70-4e6a-9a30-c2506bd2f80c",
        "definitionVersion": "6.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          },
          "excludedImages": {
            "value": "[parameters('excludedImages')]"
          },
          "excludedContainers": {
            "value": "[parameters('excludedContainers')]"
          },
          "allowedCapabilities": {
            "value": "[parameters('allowedCapabilities')]"
          },
          "requiredDropCapabilities": {
            "value": "[parameters('requiredDropCapabilities')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "allowedSeccompProfiles",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/975ce327-682c-4f2e-aa46-b9598289b86c",
        "definitionVersion": "7.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          },
          "excludedImages": {
            "value": "[parameters('excludedImages')]"
          },
          "excludedContainers": {
            "value": "[parameters('excludedContainers')]"
          },
          "allowedProfiles": {
            "value": "[parameters('allowedSeccompProfiles')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "allowedVolumeTypes",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/16697877-1118-4fb1-9b65-9898ec2509ec",
        "definitionVersion": "5.*.*",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "excludedNamespaces": {
            "value": "[parameters('excludedNamespaces')]"
          },
          "source": {
            "value": "[parameters('source')]"
          },
          "warn": {
            "value": "[parameters('warn')]"
          },
          "excludedImages": {
            "value": "[parameters('excludedImages')]"
          },
          "allowedVolumeTypes": {
            "value": "[parameters('allowedVolumeTypes')]"
          }
        }
      }
    ],
    "versions": [
      "3.1.0",
      "3.0.0",
      "2.1.1",
      "2.1.0",
      "2.0.1",
      "2.0.0-PREVIEW",
      "1.9.0-PREVIEW",
      "1.8.0-PREVIEW",
      "1.7.0-PREVIEW",
      "1.6.0-PREVIEW",
      "1.5.0-PREVIEW",
      "1.4.1-PREVIEW",
      "1.4.0-PREVIEW",
      "1.3.3-PREVIEW",
      "1.3.2-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policySetDefinitions/c047ea8e-9c78-49b2-958b-37e56d291a44",
  "name": "c047ea8e-9c78-49b2-958b-37e56d291a44"
}
Bylawc047ea8e-9c78-49b2-958b-37e56d291a44.bylaw.ps1 · 608 lines
# Converted from AKS_Safeguards.json by ConvertTo-Bylaw.
Initiative 'c047ea8e-9c78-49b2-958b-37e56d291a44' {

    Properties @{
        DisplayName   = 'Deployment safeguards should help guide developers towards AKS recommended best practices'
        Description   = 'A collection of Kubernetes best practices that are recommended by Azure Kubernetes Service (AKS). For the best experience, use deployment safeguards to assign this policy initiative: https://aka.ms/aks/deployment-safeguards. Azure Policy Add-On for AKS is a pre-requisite for applying these best practices to your clusters. For instructions on enabling the Azure Policy Add-On, go to aka.ms/akspolicydoc'
        Version       = '3.1.0'
        Category      = 'Kubernetes'
        PolicyVersion = '3.1.0'
    }

    Parameter Source @{
        AllowedValues = @('All', 'Generated', 'Original')
        Default       = 'All'
        DisplayName   = 'Source'
        Description   = 'The source k8s object for constraint evaluation. ''Original'' means only evaluate against the specific GroupVersionKind specified in the policy definition. ''Generated'' means only evaluate against k8s objects generated by Gatekeeper ExpansionTemplates. ''All'' means evaluate against both the original object and any generated ones.'
    }
    Parameter Warn @{
        Type          = 'Boolean'
        AllowedValues = @($true, $false)
        Default       = $false
        DisplayName   = 'Warn'
        Description   = 'Whether or not to return warnings back to the user in the kubectl cli'
    }
    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', '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')
        DisplayName = 'Namespace exclusions'
        Description = 'List of Kubernetes namespaces to exclude from policy evaluation.'
    }
    Parameter AllowedUsers @{
        Type        = 'Array'
        DisplayName = 'Allowed Users'
        Description = 'Users that are allowed by deployment safeguards to make changes on kubernetes object.'
    }
    Parameter AllowedGroups @{
        Type        = 'Array'
        DisplayName = 'Allowed Groups'
        Description = 'Groups that are allowed by deployment safeguards to make changes on kubernetes object.'
    }
    Parameter ExcludedContainers @{
        Type        = 'Array'
        Default     = @()
        DisplayName = 'Containers exclusions'
        Description = 'The list of InitContainers and Containers to exclude from policy evaluation. The identify is the name of container. Use an empty list to apply this policy to all containers in all namespaces.'
    }
    Parameter ExcludedImages @{
        Type        = 'Array'
        Default     = @()
        DisplayName = 'Image exclusions'
        Description = 'The list of InitContainers and Containers to exclude from policy evaluation. The identifier is the image of container. Prefix-matching can be signified with `*`. For example: `myregistry.azurecr.io/istio:*`. It is recommended that users use the fully-qualified Docker image name (e.g. start with a domain name) in order to avoid unexpectedly exempting images from an untrusted repository.'
    }
    Parameter Labels @{
        Type        = 'Array'
        DisplayName = 'AKS Specific Labels'
        Description = 'Reserved labels specific to AKS.'
    }
    Parameter AllowedContainerImagesRegex @{
        Type        = 'String'
        DisplayName = 'Allowed registry or registries regex'
        Description = 'The RegEx rule used to match allowed container image field in a Kubernetes cluster. For example, to allow any Azure Container Registry image by matching partial path: ^[^\/]+\.azurecr\.io\/.+$ and for multiple registries: ^([^\/]+\.azurecr\.io|registry\.io)\/.+$'
    }
    Parameter ReservedTaints @{
        Type        = 'Array'
        DisplayName = 'Reserved Taints'
        Description = 'Reserved taints specific to AKS'
    }
    Parameter RequiredProbes @{
        Type        = 'Array'
        Default     = @('readinessProbe', 'livenessProbe')
        DisplayName = 'Required probes list'
        Description = 'The list of probes that are required to be defined on a container. Kubernetes currently supports ''livenessProbe'', ''readinessProbe'', and ''startupProbe''.'
        Metadata    = [ordered]@{ portalReview = $true }
    }
    Parameter EffectForMutationPolicies @{
        AllowedValues = @('Mutate', 'Disabled')
        Default       = 'Disabled'
        DisplayName   = 'Mutate Effect'
        Description   = '''Mutate'' modifies a non-compliant resource to be compliant when creating or updating. ''Disabled'' turns off the policy.'
    }
    Parameter EffectForWarnOnlyPolicies @{
        AllowedValues = @('Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Print mutation annotations effect'
        Description   = '''Audit'' reports mutation annotations. ''Disabled'' turns off mutation annotation reporting.'
    }
    Parameter Messages @{
        Type        = 'Object'
        Default     = [ordered]@{  }
        DisplayName = 'Map of mutations annotations and respective messages'
        Description = 'The annotations are mapped to respective messages that will be printed upon resource mutation'
    }
    Parameter AllowedHostPorts @{
        Type        = 'Array'
        Default     = @()
        DisplayName = 'Allowed host ports list'
        Description = 'The list of specific host ports that pods are allowed to use in the host network namespace. Can include individual ports (e.g., ''80'') or port ranges (e.g., ''3000-5000''). Empty list means no host ports are allowed. Note that port 0 is not allowed according to Pod Security Standards.'
        Metadata    = [ordered]@{ portalReview = $true }
    }
    Parameter AllowedSysctls @{
        Type        = 'Array'
        Default     = @('kernel.shm_rmid_forced', 'net.ipv4.ip_local_port_range', 'net.ipv4.ip_unprivileged_port_start', 'net.ipv4.tcp_syncookies', 'net.ipv4.ping_group_range', 'net.ipv4.ip_local_reserved_ports', 'net.ipv4.tcp_keepalive_time', 'net.ipv4.tcp_fin_timeout', 'net.ipv4.tcp_keepalive_intvl', 'net.ipv4.tcp_keepalive_probes')
        DisplayName = 'Allowed sysctls'
        Description = 'The list of plain sysctl names or sysctl patterns which end with *. The string * matches all sysctls. For more information, visit https://aka.ms/k8s-policy-sysctl-interfaces.'
        Metadata    = [ordered]@{ portalReview = $true }
    }
    Parameter ForcePrivilegeEscalationToBeFalse @{
        Type        = 'Boolean'
        Default     = $false
        DisplayName = 'Force all container securityContext.allowPrivilegeEscalation fields to be explicity set to false'
        Description = 'If set to true, then `allowPrivilegeEscalation` must explicitly be set to false regardless of the `runAsUser` field in the container securityContext. Setting this value to true will make this policy follow the behavior of the Kubernetes Pod Security Standards for Privilege Escalation at the restricted level: https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted'
    }
    Parameter WindowsAllowedHostPaths @{
        Type        = 'Object'
        Default     = [ordered]@{ paths = @() }
        DisplayName = 'Allowed host paths for windows containers'
        Description = 'The host paths allowed for windows pod hostPath volumes to use. Provide an empty paths list to block all host paths. Use "C:\" to allow all windows host paths.'
        Metadata    = [ordered]@{ portalReview = $true }
        Schema      = [ordered]@{
            type = 'object'
            properties = [ordered]@{
                paths = [ordered]@{
                    type = 'array'
                    items = [ordered]@{
                        type = 'object'
                        properties = [ordered]@{
                            pathPrefix = [ordered]@{ type = 'string' }
                            readOnly = [ordered]@{ type = 'boolean' }
                        }
                        required = @('pathPrefix', 'readOnly')
                        additionalProperties = $false
                    }
                }
            }
            required = @('paths')
            additionalProperties = $false
        }
    }
    Parameter AllowedHostPaths @{
        Type        = 'Object'
        Default     = [ordered]@{ paths = @() }
        DisplayName = 'Allowed host paths'
        Description = 'The host paths allowed for pod hostPath volumes to use. Provide an empty paths list to block all host paths.'
        Metadata    = [ordered]@{ portalReview = $true }
        Schema      = [ordered]@{
            type = 'object'
            properties = [ordered]@{
                paths = [ordered]@{
                    type = 'array'
                    items = [ordered]@{
                        type = 'object'
                        properties = [ordered]@{
                            pathPrefix = [ordered]@{ type = 'string' }
                            readOnly = [ordered]@{ type = 'boolean' }
                        }
                        required = @('pathPrefix', 'readOnly')
                        additionalProperties = $false
                    }
                }
            }
            required = @('paths')
            additionalProperties = $false
        }
    }
    Parameter AllowedAppArmorProfiles @{
        Type        = 'Array'
        Default     = @('runtime/default')
        DisplayName = 'Allowed AppArmor profiles'
        Description = 'The list of AppArmor profiles that containers are allowed to use. E.g. [ "runtime/default", "docker/default" ]. Use "localhost/*" to allow all localhost profiles. Provide empty list as input to block everything.'
        Metadata    = [ordered]@{ portalReview = $true }
    }
    Parameter AllowedCapabilities @{
        Type        = 'Array'
        Default     = @()
        DisplayName = 'Allowed capabilities'
        Description = 'The list of capabilities that are allowed to be added to a container. Provide empty list as input to block everything.'
        Metadata    = [ordered]@{ portalReview = $true }
    }
    Parameter RequiredDropCapabilities @{
        Type        = 'Array'
        Default     = @()
        DisplayName = 'Required drop capabilities'
        Description = 'The list of capabilities that must be dropped by a container.'
        Metadata    = [ordered]@{ portalReview = $true }
    }
    Parameter AllowedSeccompProfiles @{
        Type        = 'Array'
        Default     = @('RuntimeDefault', 'Localhost')
        DisplayName = 'Allowed seccomp profiles'
        Description = 'The list of seccomp profiles that containers are allowed to use. E.g. ''`runtime/default`, `docker/default`, `unconfined` and/or `localhost/*`''. Provide empty list as input to block everything. Putting a `*` in this array allows all Profiles to be used.'
        Metadata    = [ordered]@{ portalReview = $true }
    }
    Parameter RunAsUserRule @{
        AllowedValues = @('MustRunAs', 'MustRunAsNonRoot', 'RunAsAny')
        Default       = 'MustRunAsNonRoot'
        DisplayName   = 'Run as user rule'
        Description   = 'The ''RunAsUser'' rule that containers are allowed to run with. MustRunAs requires at least one range to be specified. MustRunAsNonRoot requires the pod be submitted with non-zero runAsUser or have USER directive defined (using a numeric UID) in the image. RunAsAny allows any runAsUser to be specified'
        Metadata      = [ordered]@{ portalReview = $true }
    }
    Parameter RunAsUserRanges @{
        Type        = 'Object'
        Default     = [ordered]@{ ranges = @() }
        DisplayName = 'Allowed user ID ranges'
        Description = 'The user ID ranges that are allowed for containers to use. Set ''max'' as ''-1'' to skip max limit evaluation. Empty array blocks every defined value for ''MustRunAs''.'
        Metadata    = [ordered]@{ portalReview = $true }
        Schema      = [ordered]@{
            type = 'object'
            properties = [ordered]@{
                ranges = [ordered]@{
                    type = 'array'
                    items = [ordered]@{
                        type = 'object'
                        properties = [ordered]@{
                            min = [ordered]@{ type = 'integer' }
                            max = [ordered]@{ type = 'integer' }
                        }
                        required = @('min', 'max')
                        additionalProperties = $false
                    }
                }
            }
            required = @('ranges')
            additionalProperties = $false
        }
    }
    Parameter AllowedVolumeTypes @{
        Type        = 'Array'
        Default     = @()
        DisplayName = 'Allowed volume types'
        Description = 'The list of volume types that can be used by a pod. Provide empty list as input to block everything.'
        Metadata    = [ordered]@{ portalReview = $true }
    }

    PolicyDefinition @{
        Id          = '53a4a537-990c-495a-92e0-7c21a465442c'
        ReferenceId = 'restrictedNodeEditsInKubernetesCluster'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            warn               = (Param Warn)
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            allowedUsers       = (Param AllowedUsers)
            allowedGroups      = (Param AllowedGroups)
            source             = (Param Source)
        }
    }

    PolicyDefinition @{
        Id          = '03a4ecdb-0684-4039-be91-2762979e1bc8'
        ReferenceId = 'containerResourceRequests'
        Version     = '1.*.*-preview'
        Parameters  = [ordered]@{
            warn               = (Param Warn)
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            excludedImages     = (Param ExcludedImages)
            source             = (Param Source)
        }
    }

    PolicyDefinition @{
        Id          = '34c88cd4-5d72-4dbb-bf77-12c3cafe8791'
        ReferenceId = 'podEnforceAntiaffinityInKubernetesCluster'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            warn               = (Param Warn)
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
        }
    }

    PolicyDefinition @{
        Id          = 'a22123bd-b9da-4c86-9424-24903e91fd55'
        ReferenceId = 'restrictedLabelsInKubernetesCluster'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            warn               = (Param Warn)
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            allowedUsers       = (Param AllowedUsers)
            allowedGroups      = (Param AllowedGroups)
            labels             = (Param Labels)
            source             = (Param Source)
        }
    }

    PolicyDefinition @{
        Id          = 'febd0533-8e55-448f-b837-bd0e06f16469'
        ReferenceId = 'ensureAllowedContainerImagesInKubernetesCluster'
        Version     = '9.*.*'
        Parameters  = [ordered]@{
            warn                        = (Param Warn)
            effect                      = (Param Effect)
            excludedNamespaces          = (Param ExcludedNamespaces)
            allowedContainerImagesRegex = (Param AllowedContainerImagesRegex)
            excludedContainers          = (Param ExcludedContainers)
            source                      = (Param Source)
        }
    }

    PolicyDefinition @{
        Id          = '48940d92-ff05-449e-9111-e742d9280451'
        ReferenceId = 'restrictedTaintsInKubernetesCluster'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            warn               = (Param Warn)
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            reservedTaints     = (Param ReservedTaints)
            source             = (Param Source)
        }
    }

    PolicyDefinition @{
        Id          = 'b1a9997f-2883-4f12-bdff-2280f99b5915'
        ReferenceId = 'ensureProbesConfiguredInKubernetesCluster'
        Version     = '3.*.*'
        Parameters  = [ordered]@{
            warn               = (Param Warn)
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            requiredProbes     = (Param RequiredProbes)
            excludedContainers = (Param ExcludedContainers)
            excludedImages     = (Param ExcludedImages)
            source             = (Param Source)
        }
    }

    PolicyDefinition @{
        Id          = '4f3823b6-6dac-4b5a-9c61-ce1afb829f17'
        ReferenceId = 'ensureCsiDriverStorageClass'
        Version     = '2.*.*'
        Parameters  = [ordered]@{
            warn               = (Param Warn)
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
        }
    }

    PolicyDefinition @{
        Id          = 'b0fdedee-7b9e-4a17-9f5d-5e8e912d2f01'
        ReferenceId = 'uniqueServiceSelectors'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            warn               = (Param Warn)
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
        }
    }

    PolicyDefinition @{
        Id          = '021f8078-41a0-40e6-81b6-c6597da9f3ee'
        ReferenceId = 'imagesDoNotUseLatest'
        Version     = '2.*.*'
        Parameters  = [ordered]@{
            warn               = (Param Warn)
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
        }
    }

    PolicyDefinition @{
        Id          = 'e16d171b-bfe5-4d79-a525-19736b396e92'
        ReferenceId = 'mutateReservedSystemPoolTaints'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            effect             = (Param EffectForMutationPolicies)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
        }
    }

    PolicyDefinition @{
        Id          = 'e24df237-32cb-4a6c-a2f6-85b499cda9f2'
        ReferenceId = 'printMutationsAnnotations'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            effect             = (Param EffectForWarnOnlyPolicies)
            source             = (Param Source)
            warn               = (Param Warn)
            excludedNamespaces = (Param ExcludedNamespaces)
            messages           = (Param Messages)
        }
    }

    PolicyDefinition @{
        Id          = '47a1ee2f-2a2a-4576-bf2a-e0e36709c2b8'
        ReferenceId = 'blockHostNamespaces'
        Version     = '6.*.*'
        Parameters  = [ordered]@{
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
            warn               = (Param Warn)
        }
    }

    PolicyDefinition @{
        Id          = '82985f06-dc18-4a48-bc1c-b9f4f0098cfe'
        ReferenceId = 'hostNetworkPorts'
        Version     = '7.*.*'
        Parameters  = [ordered]@{
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
            warn               = (Param Warn)
            allowedHostPorts   = (Param AllowedHostPorts)
        }
    }

    PolicyDefinition @{
        Id          = '5e5a0673-649e-4d50-bf9d-5a387a4e2081'
        ReferenceId = 'allowedSysctls'
        Version     = '1.*.*-preview'
        Parameters  = [ordered]@{
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
            warn               = (Param Warn)
            allowedSysctls     = (Param AllowedSysctls)
        }
    }

    PolicyDefinition @{
        Id          = 'f06ddb64-5fa3-4b77-b166-acb36f7f6042'
        ReferenceId = 'allowedUsersGroups'
        Version     = '6.*.*'
        Parameters  = [ordered]@{
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
            warn               = (Param Warn)
            excludedImages     = (Param ExcludedImages)
            excludedContainers = (Param ExcludedContainers)
            runAsUserRule      = (Param RunAsUserRule)
            runAsUserRanges    = (Param RunAsUserRanges)
        }
    }

    PolicyDefinition @{
        Id          = '5485eac0-7e8f-4964-998b-a44f4f0c1e75'
        ReferenceId = 'windowsBlockContainerAdmin'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
            warn               = (Param Warn)
            excludedImages     = (Param ExcludedImages)
        }
    }

    PolicyDefinition @{
        Id          = '1c6e92c9-99f0-4e55-9cf2-0c234dc48f99'
        ReferenceId = 'containerNoPrivilegeEscalation'
        Version     = '8.*.*'
        Parameters  = [ordered]@{
            effect                            = (Param Effect)
            excludedNamespaces                = (Param ExcludedNamespaces)
            source                            = (Param Source)
            warn                              = (Param Warn)
            excludedImages                    = (Param ExcludedImages)
            excludedContainers                = (Param ExcludedContainers)
            forcePrivilegeEscalationToBeFalse = (Param ForcePrivilegeEscalationToBeFalse)
        }
    }

    PolicyDefinition @{
        Id          = '098fc59e-46c7-4d99-9b16-64990e543d75'
        ReferenceId = 'allowedHostPaths'
        Version     = '6.*.*'
        Parameters  = [ordered]@{
            effect                  = (Param Effect)
            excludedNamespaces      = (Param ExcludedNamespaces)
            source                  = (Param Source)
            warn                    = (Param Warn)
            excludedImages          = (Param ExcludedImages)
            excludedContainers      = (Param ExcludedContainers)
            allowedHostPaths        = (Param AllowedHostPaths)
            windowsAllowedHostPaths = (Param WindowsAllowedHostPaths)
        }
    }

    PolicyDefinition @{
        Id          = '511f5417-5d12-434d-ab2e-816901e72a5e'
        ReferenceId = 'enforceAppArmorProfile'
        Version     = '6.*.*'
        Parameters  = [ordered]@{
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
            warn               = (Param Warn)
            excludedImages     = (Param ExcludedImages)
            excludedContainers = (Param ExcludedContainers)
            allowedProfiles    = (Param AllowedAppArmorProfiles)
        }
    }

    PolicyDefinition @{
        Id          = 'e1e6c427-07d9-46ab-9689-bfa85431e636'
        ReferenceId = 'enforceSELinux'
        Version     = '8.*.*'
        Parameters  = [ordered]@{
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
            warn               = (Param Warn)
            excludedImages     = (Param ExcludedImages)
            enforcePSS         = $true
        }
    }

    PolicyDefinition @{
        Id          = '077f0ce1-86d6-4058-bc60-de05067e8622'
        ReferenceId = 'windowsBlockHostProcess'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
            warn               = (Param Warn)
            excludedImages     = (Param ExcludedImages)
        }
    }

    PolicyDefinition @{
        Id          = '95edb821-ddaf-4404-9732-666045e056b4'
        ReferenceId = 'privilegedContainers'
        Version     = '9.*.*'
        Parameters  = [ordered]@{
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
            warn               = (Param Warn)
            excludedImages     = (Param ExcludedImages)
            excludedContainers = (Param ExcludedContainers)
        }
    }

    PolicyDefinition @{
        Id          = 'f85eb0dd-92ee-40e9-8a76-db25a507d6d3'
        ReferenceId = 'allowedProcMountType'
        Version     = '8.*.*'
        Parameters  = [ordered]@{
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
            warn               = (Param Warn)
            excludedImages     = (Param ExcludedImages)
            excludedContainers = (Param ExcludedContainers)
        }
    }

    PolicyDefinition @{
        Id          = 'c26596ff-4d70-4e6a-9a30-c2506bd2f80c'
        ReferenceId = 'containerAllowedCapabilities'
        Version     = '6.*.*'
        Parameters  = [ordered]@{
            effect                   = (Param Effect)
            excludedNamespaces       = (Param ExcludedNamespaces)
            source                   = (Param Source)
            warn                     = (Param Warn)
            excludedImages           = (Param ExcludedImages)
            excludedContainers       = (Param ExcludedContainers)
            allowedCapabilities      = (Param AllowedCapabilities)
            requiredDropCapabilities = (Param RequiredDropCapabilities)
        }
    }

    PolicyDefinition @{
        Id          = '975ce327-682c-4f2e-aa46-b9598289b86c'
        ReferenceId = 'allowedSeccompProfiles'
        Version     = '7.*.*'
        Parameters  = [ordered]@{
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
            warn               = (Param Warn)
            excludedImages     = (Param ExcludedImages)
            excludedContainers = (Param ExcludedContainers)
            allowedProfiles    = (Param AllowedSeccompProfiles)
        }
    }

    PolicyDefinition @{
        Id          = '16697877-1118-4fb1-9b65-9898ec2509ec'
        ReferenceId = 'allowedVolumeTypes'
        Version     = '5.*.*'
        Parameters  = [ordered]@{
            effect             = (Param Effect)
            excludedNamespaces = (Param ExcludedNamespaces)
            source             = (Param Source)
            warn               = (Param Warn)
            excludedImages     = (Param ExcludedImages)
            allowedVolumeTypes = (Param AllowedVolumeTypes)
        }
    }
}

Members (27)

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