Bylaw

Gallery › Kubernetes › Azure built-in policies

Cannot Edit Individual Nodes

Doesn't convert yet Policy Audit Deny Disabled Mode Microsoft.Kubernetes.Data Version 1.3.1

Cannot Edit Individual Nodes. Users should not edit individual nodes. Please edit node pools. Modifying individual nodes can lead to inconsistent settings, operational challenges, and potential security risks.

ConvertTo-Bylaw can't convert this policy yet:

Azure Policy JSONCannotEditIndividualNodes.json · 193 lines
{
  "properties": {
    "displayName": "Cannot Edit Individual Nodes",
    "policyType": "BuiltIn",
    "mode": "Microsoft.Kubernetes.Data",
    "description": "Cannot Edit Individual Nodes. Users should not edit individual nodes. Please edit node pools. Modifying individual nodes can lead to inconsistent settings, operational challenges, and potential security risks.",
    "metadata": {
      "version": "1.3.1",
      "category": "Kubernetes"
    },
    "version": "1.3.1",
    "parameters": {
      "source": {
        "type": "String",
        "metadata": {
          "displayName": "Source",
          "description": "The source k8s object for constraint evaluation. 'Original' means only evaluate against the specific GroupVersionKind specified in the policy definition. 'Generated' means only evaluate against k8s objects generated by Gatekeeper ExpansionTemplates. 'All' means evaluate against both the original object and any generated ones."
        },
        "defaultValue": "Original",
        "allowedValues": [
          "All",
          "Generated",
          "Original"
        ]
      },
      "warn": {
        "type": "Boolean",
        "metadata": {
          "displayName": "Warn",
          "description": "Whether or not to return warnings back to the user in the kubectl cli"
        },
        "defaultValue": false
      },
      "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": []
      },
      "labelSelector": {
        "type": "Object",
        "metadata": {
          "displayName": "Kubernetes label selector",
          "description": "Label query to select Kubernetes resources for policy evaluation. An empty label selector matches all Kubernetes resources."
        },
        "defaultValue": {},
        "schema": {
          "description": "A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all resources.",
          "type": "object",
          "properties": {
            "matchLabels": {
              "description": "matchLabels is a map of {key,value} pairs.",
              "type": "object",
              "additionalProperties": {
                "type": "string"
              },
              "minProperties": 1
            },
            "matchExpressions": {
              "description": "matchExpressions is a list of values, a key, and an operator.",
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "key": {
                    "description": "key is the label key that the selector applies to.",
                    "type": "string"
                  },
                  "operator": {
                    "description": "operator represents a key's relationship to a set of values.",
                    "type": "string",
                    "enum": [
                      "In",
                      "NotIn",
                      "Exists",
                      "DoesNotExist"
                    ]
                  },
                  "values": {
                    "description": "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty.",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "key",
                  "operator"
                ],
                "additionalProperties": false
              },
              "minItems": 1
            }
          },
          "additionalProperties": false
        }
      },
      "allowedUsers": {
        "type": "Array",
        "metadata": {
          "displayName": "Allowed Users",
          "description": "Users that are allowed by deployment safeguards to modify node labels on individual nodes."
        },
        "defaultValue": [
          "nodeclient",
          "system:serviceaccount:kube-system:aci-connector-linux",
          "system:serviceaccount:kube-system:node-controller",
          "acsService",
          "aksService",
          "system:serviceaccount:kube-system:cloud-node-manager"
        ]
      },
      "allowedGroups": {
        "type": "Array",
        "metadata": {
          "displayName": "Allowed Groups",
          "description": "Groups that are allowed by deployment safeguards to modify node labels on individual nodes."
        },
        "defaultValue": [
          "system:node"
        ]
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.ContainerService/managedClusters"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "source": "[parameters('source')]",
          "warn": "[parameters('warn')]",
          "templateInfo": {
            "sourceType": "PublicURL",
            "url": "https://store.policy.core.windows.net/kubernetes/restricted-node-edits/v1/template.yaml"
          },
          "apiGroups": [
            ""
          ],
          "kinds": [
            "Node"
          ],
          "namespaces": "[parameters('namespaces')]",
          "excludedNamespaces": "[parameters('excludedNamespaces')]",
          "labelSelector": "[parameters('labelSelector')]",
          "values": {
            "allowedUsers": "[parameters('allowedUsers')]",
            "allowedGroups": "[parameters('allowedGroups')]"
          }
        }
      }
    },
    "versions": [
      "1.3.1",
      "1.3.0-PREVIEW",
      "1.2.0-PREVIEW",
      "1.1.1-PREVIEW",
      "1.1.0-PREVIEW",
      "1.0.3-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/53a4a537-990c-495a-92e0-7c21a465442c",
  "name": "53a4a537-990c-495a-92e0-7c21a465442c"
}

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