last sync: 2020-Jul-10 14:05:01 UTC

Azure Policy

[Preview]: Ensure only allowed container images in Kubernetes cluster

Policy DisplayName [Preview]: Ensure only allowed container images in Kubernetes cluster
Policy Id febd0533-8e55-448f-b837-bd0e06f16469
Policy Category Kubernetes
Policy Description This policy ensures only allowed container images are running in a Kubernetes cluster. For instructions on using this policy, visit https://aka.ms/kubepolicydoc.
Policy Mode Microsoft.Kubernetes.Data
Policy Type BuiltIn
Policy in Preview True
Policy Deprecated FALSE
Policy Effect Default: deny
Allowed: (audit,deny,disabled)
Roles used none
Policy Changes
Date/Time (UTC ymd) (i) Change Change detail
2020-04-23 15:06:19 change: DisplayName previous DisplayName: [Preview]: [AKS Engine] Ensure only allowed container images in Kubernetes cluster
2019-10-29 23:04:36 add: Policy febd0533-8e55-448f-b837-bd0e06f16469
Used in Policy Initiative(s) none
Policy Rule
{
  "properties": {
  "displayName": "[Preview]: Ensure only allowed container images in Kubernetes cluster",
    "policyType": "BuiltIn",
    "mode": "Microsoft.Kubernetes.Data",
    "description": "This policy ensures only allowed container images are running in a Kubernetes cluster. For instructions on using this policy, visit https://aka.ms/kubepolicydoc.",
    "metadata": {
      "version": "4.0.0-preview",
      "category": "Kubernetes",
      "preview": true
    },
    "parameters": {
      "allowedContainerImagesRegex": {
        "type": "String",
        "metadata": {
        "displayName": "[Preview]: Allowed container images regex",
          "description": "The RegEx rule used to match allowed container images in a Kubernetes cluster. For example, to allow any Azure Container Registry image by matching partial path: ^.+azurecr.io/.+$"
        }
      },
      "effect": {
        "type": "String",
        "metadata": {
        "displayName": "[Preview]: Effect",
          "description": "'Audit' allows a non-compliant resource to be created, but flags it as non-compliant. 'Deny' blocks the resource creation. 'Disable' turns off the policy."
        },
        "allowedValues": [
          "audit",
          "deny",
          "disabled"
        ],
        "defaultValue": "deny"
      },
      "excludedNamespaces": {
        "type": "Array",
        "metadata": {
        "displayName": "[Preview]: Namespace exclusions",
          "description": "List of Kubernetes namespaces to exclude from policy evaluation."
        },
        "defaultValue": [
          "kube-system",
          "gatekeeper-system",
          "azure-arc"
        ]
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "in": [
          "AKS Engine",
          "Microsoft.Kubernetes/connectedClusters",
          "Microsoft.ContainerService/managedClusters"
        ]
      },
      "then": {
      "effect": "[parameters('effect')]",
        "details": {
          "constraintTemplate": "https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-references/Kubernetes/container-allowed-images/template.yaml",
          "constraint": "https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-references/Kubernetes/container-allowed-images/constraint.yaml",
          "values": {
          "allowedContainerImagesRegex": "[parameters('allowedContainerImagesRegex')]",
          "excludedNamespaces": "[parameters('excludedNamespaces')]"
          }
        }
      }
    }
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/febd0533-8e55-448f-b837-bd0e06f16469",
  "type": "Microsoft.Authorization/policyDefinitions",
  "name": "febd0533-8e55-448f-b837-bd0e06f16469"
}