last sync: 2021-May-14 16:08:20 UTC

Azure Policy definition

Kubernetes cluster containers should only use allowed images

Name Kubernetes cluster containers should only use allowed images
Azure Portal
Id febd0533-8e55-448f-b837-bd0e06f16469
Version 6.1.0
details on versioning
Category Kubernetes
Microsoft docs
Description Use images from trusted registries to reduce the Kubernetes cluster's exposure risk to unknown vulnerabilities, security issues and malicious images. This policy is generally available for Kubernetes Service (AKS), and preview for AKS Engine and Azure Arc enabled Kubernetes. For more information, see https://aka.ms/kubepolicydoc.
Mode Microsoft.Kubernetes.Data
Type BuiltIn
Preview FALSE
Deprecated FALSE
Effect Default: deny
Allowed: (audit, deny, disabled)
Used RBAC Role none
History
Date/Time (UTC ymd) (i) Change type Change detail
2021-03-09 14:37:41 change Minor (6.0.0 > 6.1.0)
2021-03-02 15:11:40 change Major (5.0.1 > 6.0.0)
2020-12-11 15:42:52 change Major (4.0.1 > 5.0.1)
2020-09-15 14:06:41 change Previous DisplayName: [Preview]: Ensure only allowed container images in Kubernetes cluster
2020-04-23 15:06:19 change Previous DisplayName: [Preview]: [AKS Engine] Ensure only allowed container images in Kubernetes cluster
2019-10-29 23:04:36 add febd0533-8e55-448f-b837-bd0e06f16469
Used in Initiatives
Initiative DisplayName Initiative Id Initiative Category State
[Deprecated]: Azure Security Benchmark v2 bb522ac1-bc39-4957-b194-429bcd3bcb0b Regulatory Compliance Deprecated
Azure Security Benchmark 1f3afdf9-d0c9-4c3d-847f-89da613e70a8 Security Center GA
JSON Changes

JSON
{
  "properties": {
    "displayName": "Kubernetes cluster containers should only use allowed images",
    "policyType": "BuiltIn",
    "mode": "Microsoft.Kubernetes.Data",
    "description": "Use images from trusted registries to reduce the Kubernetes cluster's exposure risk to unknown vulnerabilities, security issues and malicious images. This policy is generally available for Kubernetes Service (AKS), and preview for AKS Engine and Azure Arc enabled Kubernetes. For more information, see https://aka.ms/kubepolicydoc.",
    "metadata": {
      "version": "6.1.0",
      "category": "Kubernetes"
    },
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "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": "Namespace exclusions",
          "description": "List of Kubernetes namespaces to exclude from policy evaluation."
        },
        "defaultValue": [
          "kube-system",
          "gatekeeper-system",
          "azure-arc"
        ]
      },
      "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": [
          
        ]
      },
      "labelSelector": {
        "type": "Object",
        "metadata": {
          "displayName": "Kubernetes label selector",
          "description": "Label query to select Kubernetes resources for policy evaluation. An empty label selector matches all Kubernetes resources."
        },
        "defaultValue": {
          
        }
      },
      "allowedContainerImagesRegex": {
        "type": "String",
        "metadata": {
          "displayName": "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/.+$"
        }
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "in": [
          "AKS Engine",
          "Microsoft.Kubernetes/connectedClusters",
          "Microsoft.ContainerService/managedClusters"
        ]
      },
      "then": {
      "effect": "[parameters('effect')]",
        "details": {
          "constraintTemplate": "https://store.policy.core.windows.net/kubernetes/container-allowed-images/v1/template.yaml",
          "constraint": "https://store.policy.core.windows.net/kubernetes/container-allowed-images/v1/constraint.yaml",
        "excludedNamespaces": "[parameters('excludedNamespaces')]",
        "namespaces": "[parameters('namespaces')]",
        "labelSelector": "[parameters('labelSelector')]",
          "values": {
          "allowedContainerImagesRegex": "[parameters('allowedContainerImagesRegex')]",
          "imageRegex": "[parameters('allowedContainerImagesRegex')]"
          }
        }
      }
    }
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/febd0533-8e55-448f-b837-bd0e06f16469",
  "type": "Microsoft.Authorization/policyDefinitions",
  "name": "febd0533-8e55-448f-b837-bd0e06f16469"
}