Bylaw

Gallery › Kubernetes › Azure Community Policy

Ensure only allowed Volume Types are used in Kubernetes Cluster

Doesn't convert yet Policy Audit Deny Disabled Mode Microsoft.Kubernetes.Data Version 1.0.0 Preview

This policy ensures only allowed volume types are used in a Kubernetes cluster. For instructions on using this policy, please visit https://aka.ms/kubepolicydoc

ConvertTo-Bylaw can't convert this policy yet:

Azure Policy JSONazurepolicy.json · 71 lines
{
  "properties": {
    "displayName": "Ensure only allowed Volume Types are used in Kubernetes Cluster",
    "policyType": "Custom",
    "mode": "Microsoft.Kubernetes.Data",
    "description": "This policy ensures only allowed volume types are used in a Kubernetes cluster. For instructions on using this policy, please visit https://aka.ms/kubepolicydoc",
    "metadata": {
      "version": "1.0.0",
      "category": "Kubernetes",
      "preview": true
    },
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of 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. Providing a value for this parameter is optional."
        },
        "defaultValue": [
          "kube-system",
          "gatekeeper-system",
          "azure-arc"
        ]
      },
      "allowedVolumeTypes": {
        "type": "Array",
        "metadata": {
          "displayName": "Allowed Volume Types",
          "description": "List of volume types that volumes are allowed to use. Use * to allow all volume types. Empty array means all volume types are disallowed."
        },
        "defaultValue": []
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "in": [
          "AKS Engine",
          "Microsoft.Kubernetes/connectedClusters",
          "Microsoft.ContainerService/managedClusters"
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "constraintTemplate": "https://raw.githubusercontent.com/Azure/Community-Policy/master/policyDefinitions/Kubernetes/allowed-volume-types/template.yaml",
          "constraint": "https://raw.githubusercontent.com/Azure/Community-Policy/master/policyDefinitions/Kubernetes/allowed-volume-types/constraint.yaml",
          "values": {
            "excludedNamespaces": "[parameters('excludedNamespaces')]",
            "allowedVolumeTypes": "[parameters('allowedVolumeTypes')]"
          }
        }
      }
    }
  },
  "type": "Microsoft.Authorization/policyDefinitions",
  "name": "418bd3c0-39ab-4b41-98ef-a9727752b301"
}

Source: policyDefinitions/Kubernetes/allowed-volume-types/azurepolicy.json in Azure/Community-Policy, under the MIT licence.