last sync: 2020-Oct-20 13:29:33 UTC

Azure Policy

Kubernetes cluster pod hostPath volumes should only use allowed host paths

Name Kubernetes cluster pod hostPath volumes should only use allowed host paths
Id 098fc59e-46c7-4d99-9b16-64990e543d75
Version 1.0.1
details on versioning
Category Kubernetes
Description This policy ensures pod hostPath volumes can only use allowed host paths in a Kubernetes Cluster. This policy is generally available for Kubernetes Service (AKS), and preview for AKS Engine and Azure Arc enabled Kubernetes. For instructions on using this policy, visit https://aka.ms/kubepolicydoc.
Mode Microsoft.Kubernetes.Data
Type BuiltIn
Preview FALSE
Deprecated FALSE
Effect Default: audit
Allowed: (audit,deny,disabled)
Used RBAC Role none
History
Date/Time (UTC ymd) (i) Change type Change detail
2020-09-15 14:06:41 change Previous DisplayName: [Preview]: Kubernetes cluster pod hostPath volumes should only use allowed host paths
2020-07-08 14:28:08 add 098fc59e-46c7-4d99-9b16-64990e543d75
Used in Initiatives
Initiative DisplayName Initiative Id
Enable Monitoring in Azure Security Center 1f3afdf9-d0c9-4c3d-847f-89da613e70a8
Kubernetes cluster pod security baseline standards for Linux-based workloads a8640138-9b0a-4a28-b8cb-1666c838647d
Json
{
  "properties": {
    "displayName": "Kubernetes cluster pod hostPath volumes should only use allowed host paths",
    "policyType": "BuiltIn",
    "mode": "Microsoft.Kubernetes.Data",
    "description": "This policy ensures pod hostPath volumes can only use allowed host paths in a Kubernetes Cluster. This policy is generally available for Kubernetes Service (AKS), and preview for AKS Engine and Azure Arc enabled Kubernetes. For instructions on using this policy, visit https://aka.ms/kubepolicydoc.",
    "metadata": {
      "version": "1.0.1",
      "category": "Kubernetes"
    },
    "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",
          "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"
        ]
      },
      "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.",
          "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
          }
        },
        "defaultValue": {
          "paths": [
            
          ]
        }
      }
    },
    "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/allowed-host-paths/template.yaml",
          "constraint": "https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-references/Kubernetes/allowed-host-paths/constraint.yaml",
          "values": {
          "allowedHostPaths": "[parameters('allowedHostPaths').paths]",
          "excludedNamespaces": "[parameters('excludedNamespaces')]"
          }
        }
      }
    }
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/098fc59e-46c7-4d99-9b16-64990e543d75",
  "type": "Microsoft.Authorization/policyDefinitions",
  "name": "098fc59e-46c7-4d99-9b16-64990e543d75"
}