Gallery › Kubernetes › Azure Community Policy
Ensure only allowed External IPs 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 external ips 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:
- BYL6002 Its mode, Microsoft.Kubernetes.Data, is a resource provider mode, which language version 1.0 doesn't support.
Azure Policy JSONazurepolicy.json · 71 lines
{
"properties": {
"displayName": "Ensure only allowed External IPs are used in Kubernetes Cluster",
"policyType": "Custom",
"mode": "Microsoft.Kubernetes.Data",
"description": "This policy ensures only allowed external ips 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"
]
},
"allowedExternalIPs": {
"type": "Array",
"metadata": {
"displayName": "Allowed External IPs",
"description": "List of External IPs that services are allowed to use. Empty array means all external IPs 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-external-ips/template.yaml",
"constraint": "https://raw.githubusercontent.com/Azure/Community-Policy/master/policyDefinitions/Kubernetes/allowed-external-ips/constraint.yaml",
"values": {
"excludedNamespaces": "[parameters('excludedNamespaces')]",
"allowedExternalIPs": "[parameters('allowedExternalIPs')]"
}
}
}
}
},
"type": "Microsoft.Authorization/policyDefinitions",
"name": "849ba427-0b66-4052-9ff1-429004878aff"
}Source: policyDefinitions/Kubernetes/allowed-external-ips/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw