Bylaw

Gallery › Kubernetes › Azure built-in policies

[Deprecated]: Enforce unique ingress hostnames across namespaces in Kubernetes cluster

Doesn't convert yet Policy Audit Deny Disabled Mode Microsoft.Kubernetes.Data Version 4.1.0-deprecated Deprecated

This policy enforces unique ingress hostnames across namespaces 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:

Azure Policy JSONIngressHostnamesConflict.json · 78 lines
{
  "properties": {
    "displayName": "[Deprecated]: Enforce unique ingress hostnames across namespaces in Kubernetes cluster",
    "policyType": "BuiltIn",
    "mode": "Microsoft.Kubernetes.Data",
    "description": "This policy enforces unique ingress hostnames across namespaces in a Kubernetes cluster. For instructions on using this policy, please go to https://aka.ms/kubepolicydoc.",
    "metadata": {
      "version": "4.1.0-deprecated",
      "category": "Kubernetes",
      "deprecated": true
    },
    "version": "4.1.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "'Audit' allows a non-compliant resource to be created, but flags it as non-compliant. 'Deny' blocks the resource creation. 'Disable' turns off the policy."
        },
        "allowedValues": [
          "audit",
          "Audit",
          "deny",
          "Deny",
          "disabled",
          "Disabled"
        ],
        "defaultValue": "Deny"
      },
      "excludedNamespaces": {
        "type": "Array",
        "metadata": {
          "displayName": "Namespace exclusions",
          "description": "List of Kubernetes namespaces to exclude from policy evaluation. System namespaces \"kube-system\", \"gatekeeper-system\" and \"azure-arc\" are always excluded by design."
        },
        "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": []
      }
    },
    "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/ingress-hostnames-conflict/template.yaml",
          "constraint": "https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-references/Kubernetes/ingress-hostnames-conflict/constraint.yaml",
          "excludedNamespaces": "[parameters('excludedNamespaces')]",
          "namespaces": "[parameters('namespaces')]",
          "values": {
            "excludedNamespaces": "[parameters('excludedNamespaces')]"
          }
        }
      }
    },
    "versions": [
      "4.1.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/b2fd3e59-6390-4f2b-8247-ea676bd03e2d",
  "name": "b2fd3e59-6390-4f2b-8247-ea676bd03e2d"
}

Source: built-in-policies/policyDefinitions/Kubernetes/IngressHostnamesConflict.json in Azure/azure-policy, under the MIT licence.