last sync: 2021-Jan-15 16:07:21 UTC

Azure Policy definition

Kubernetes cluster pods and containers should only use allowed SELinux options

Name Kubernetes cluster pods and containers should only use allowed SELinux options
Azure Portal
Id e1e6c427-07d9-46ab-9689-bfa85431e636
Version 3.0.1
details on versioning
Category Kubernetes
Microsoft docs
Description This policy ensures pods and containers only use allowed SELinux options 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-12-11 15:42:52 change Major (2.0.1 > 3.0.1)
2020-09-15 14:06:41 change Previous DisplayName: [Preview]: Kubernetes cluster pods and containers should only use allowed SELinux options
2020-07-08 14:28:08 add e1e6c427-07d9-46ab-9689-bfa85431e636
Used in Initiatives none
JSON Changes

Json
{
  "properties": {
    "displayName": "Kubernetes cluster pods and containers should only use allowed SELinux options",
    "policyType": "BuiltIn",
    "mode": "Microsoft.Kubernetes.Data",
    "description": "This policy ensures pods and containers only use allowed SELinux options 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": "3.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"
        ]
      },
      "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": [
          
        ]
      },
      "allowedSELinuxOptions": {
        "type": "Object",
        "metadata": {
          "displayName": "Allowed SELinux options",
          "description": "The allowed configurations for pod and container level SELinux Options. Provide empty options list as input to block everything.",
          "schema": {
            "type": "object",
            "properties": {
              "options": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "level": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "user": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "options"
            ],
            "additionalProperties": false
          }
        },
        "defaultValue": {
          "options": [
            
          ]
        }
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "in": [
          "AKS Engine",
          "Microsoft.Kubernetes/connectedClusters"
        ]
      },
      "then": {
      "effect": "[parameters('effect')]",
        "details": {
          "constraintTemplate": "https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-references/Kubernetes/selinux/template.yaml",
          "constraint": "https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-references/Kubernetes/selinux/constraint.yaml",
        "excludedNamespaces": "[parameters('excludedNamespaces')]",
        "namespaces": "[parameters('namespaces')]",
          "values": {
          "excludedNamespaces": "[parameters('excludedNamespaces')]",
          "allowedSELinuxOptions": "[parameters('allowedSELinuxOptions').options]"
          }
        }
      }
    }
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/e1e6c427-07d9-46ab-9689-bfa85431e636",
  "type": "Microsoft.Authorization/policyDefinitions",
  "name": "e1e6c427-07d9-46ab-9689-bfa85431e636"
}