Bylaw

Gallery › Kubernetes › Azure Community Policy

Ensure only allowed capabilities 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 specified security capabilities are defined and removed inside 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 · 80 lines
{
  "properties": {
    "displayName": "Ensure only allowed capabilities are used in Kubernetes Cluster",
    "policyType": "Custom",
    "mode": "Microsoft.Kubernetes.Data",
    "description": "This policy ensures specified security capabilities are defined and removed inside 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"
        ]
      },
      "allowedCapabilities": {
        "type": "Array",
        "metadata": {
          "displayName": "Allowed capabilities",
          "description": "List of capabilities that containers are able to use"
        },
        "defaultValue": []
      },
      "requiredDropCapabilities": {
        "type": "Array",
        "metadata": {
          "displayName": "Required Drop Capabilities",
          "description": "List of capabilities that containers must drop to be allowed to run"
        },
        "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/container-allowed-capabilities/template.yaml",
          "constraint": "https://raw.githubusercontent.com/Azure/Community-Policy/master/policyDefinitions/Kubernetes/container-allowed-capabilities/constraint.yaml",
          "values": {
            "excludedNamespaces": "[parameters('excludedNamespaces')]",
            "allowedCapabilities": "[parameters('allowedCapabilities')]",
            "requiredDropCapabilities": "[parameters('requiredDropCapabilities')]"
          }
        }
      }
    }
  },
  "type": "Microsoft.Authorization/policyDefinitions",
  "name": "b78635dd-cf1b-4ad4-a6d1-3d1b2f4a176a"
}

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