last sync: 2020-Sep-23 13:42:45 UTC

Azure Policy

Ensure container CPU and memory resource limits do not exceed the specified limits in Kubernetes cluster

Policy DisplayName Ensure container CPU and memory resource limits do not exceed the specified limits in Kubernetes cluster
Policy Id e345eecc-fa47-480f-9e88-67dcc122b164
Policy Category Kubernetes
Policy Description This policy ensures container CPU and memory resource limits are defined and do not exceed the specified limits in a Kubernetes cluster. For instructions on using this policy, visit https://aka.ms/kubepolicydoc.
Policy Mode Microsoft.Kubernetes.Data
Policy Type BuiltIn
Policy in Preview FALSE
Policy Deprecated FALSE
Policy Effect Default: deny
Allowed: (audit,deny,disabled)
Roles used none
Policy Changes
Date/Time (UTC ymd) (i) Change Change detail
2020-09-15 14:06:41 change: DisplayName previous DisplayName: [Preview]: Ensure container CPU and memory resource limits do not exceed the specified limits in Kubernetes cluster
2020-04-23 15:06:19 change: DisplayName previous DisplayName: [Preview]: [AKS Engine] Ensure container CPU and memory resource limits do not exceed the specified limits in Kubernetes cluster
2019-10-29 23:04:36 add: Policy e345eecc-fa47-480f-9e88-67dcc122b164
Used in Policy Initiative(s)
Initiative DisplayName Initiative Id
Enable Monitoring in Azure Security Center 1f3afdf9-d0c9-4c3d-847f-89da613e70a8
Policy Rule
{
  "properties": {
    "displayName": "Ensure container CPU and memory resource limits do not exceed the specified limits in Kubernetes cluster",
    "policyType": "BuiltIn",
    "mode": "Microsoft.Kubernetes.Data",
    "description": "This policy ensures container CPU and memory resource limits are defined and do not exceed the specified limits in a Kubernetes cluster. For instructions on using this policy, visit https://aka.ms/kubepolicydoc.",
    "metadata": {
      "version": "4.0.1",
      "category": "Kubernetes"
    },
    "parameters": {
      "cpuLimit": {
        "type": "String",
        "metadata": {
          "displayName": "Max allowed CPU units",
          "description": "The maximum CPU units allowed for a container. E.g. 200m. For more information, please refer https://aka.ms/k8s-policy-pod-limits"
        }
      },
      "memoryLimit": {
        "type": "String",
        "metadata": {
          "displayName": "Max allowed memory bytes",
          "description": "The maximum memory bytes allowed for a container. E.g. 1Gi. For more information, please refer https://aka.ms/k8s-policy-pod-limits"
        }
      },
      "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",
          "deny",
          "disabled"
        ],
        "defaultValue": "deny"
      },
      "excludedNamespaces": {
        "type": "Array",
        "metadata": {
          "displayName": "Namespace exclusions",
          "description": "List of Kubernetes namespaces to exclude from policy evaluation."
        },
        "defaultValue": [
          "kube-system",
          "gatekeeper-system",
          "azure-arc"
        ]
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "in": [
          "AKS Engine",
          "Microsoft.Kubernetes/connectedClusters",
          "Microsoft.ContainerService/managedClusters"
        ]
      },
      "then": {
      "effect": "[parameters('effect')]",
        "details": {
          "constraintTemplate": "https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-references/Kubernetes/container-resource-limits/template.yaml",
          "constraint": "https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-references/Kubernetes/container-resource-limits/constraint.yaml",
          "values": {
          "cpuLimit": "[parameters('cpuLimit')]",
          "memoryLimit": "[parameters('memoryLimit')]",
          "excludedNamespaces": "[parameters('excludedNamespaces')]"
          }
        }
      }
    }
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/e345eecc-fa47-480f-9e88-67dcc122b164",
  "type": "Microsoft.Authorization/policyDefinitions",
  "name": "e345eecc-fa47-480f-9e88-67dcc122b164"
}