Bylaw

Gallery › Kubernetes › Azure Community Policy

Ensure Read-Only Access to Root Filesystem in a Kubernetes Cluster

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

This policy ensures pods only have read-only access to the root filesystem 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 · 61 lines
{
  "name": "48ab964d-5477-47fc-95c5-9cf926f8cd1d",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Ensure Read-Only Access to Root Filesystem in a Kubernetes Cluster",
    "description": "This policy ensures pods only have read-only access to the root filesystem in a Kubernetes cluster. For instructions on using this policy, please visit https://aka.ms/kubepolicydoc/.",
    "metadata": {
      "version": "1.0.0-preview",
      "category": "Kubernetes",
      "preview": true
    },
    "mode": "Microsoft.Kubernetes.Data",
    "parameters": {
      "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"
        ]
      },
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Deny, Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Deny",
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "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/ensure-read-only-access-to-root-filesystem-in-a-kubernetes-cluster/template.yaml",
          "constraint": "https://raw.githubusercontent.com/Azure/Community-Policy/master/policyDefinitions/Kubernetes/ensure-read-only-access-to-root-filesystem-in-a-kubernetes-cluster/constraint.yaml",
          "values": {
            "excludedNamespaces": "[parameters('excludedNamespaces')]"
          }
        }
      }
    }
  }
}

Source: policyDefinitions/Kubernetes/ensure-read-only-access-to-root-filesystem-in-a-kubernetes-cluster/azurepolicy.json in Azure/Community-Policy, under the MIT licence.