Gallery › Kubernetes › Azure Community Policy
Block usage of the default namespace in a Kubernetes cluster
Doesn't convert yet Policy Audit Deny Disabled Mode Microsoft.Kubernetes.Data Version 1.0.0-preview Preview
This policy blocks usage of the default namespace in a Kubernetes cluster. For instructions on using this policy, please go to https://aka.ms/kubepolicydoc.
ConvertTo-Bylaw can't convert this policy yet:
- BYL6002 Its mode, Microsoft.Kubernetes.Data, is a resource provider mode, which language version 1.0 doesn't support.
Azure Policy JSONazurepolicy.json · 61 lines
{
"name": "6480c6e8-f25e-44d2-bdad-ab4585cdd99e",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Block usage of the default namespace in a Kubernetes cluster",
"description": "This policy blocks usage of the default namespace in a Kubernetes cluster. For instructions on using this policy, please go to 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/block-usage-of-the-default-namespace-in-a-kubernetes-cluster/template.yaml",
"constraint": "https://raw.githubusercontent.com/Azure/Community-Policy/master/policyDefinitions/Kubernetes/block-usage-of-the-default-namespace-in-a-kubernetes-cluster/constraint.yaml",
"values": {
"excludedNamespaces": "[parameters('excludedNamespaces')]"
}
}
}
}
}
}Source: policyDefinitions/Kubernetes/block-usage-of-the-default-namespace-in-a-kubernetes-cluster/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw