last sync: 2020-Aug-05 13:05:29 UTC

Azure Policy

[Preview]: Kubernetes cluster pods and containers should only run with approved user and group IDs

Policy DisplayName [Preview]: Kubernetes cluster pods and containers should only run with approved user and group IDs
Policy Id f06ddb64-5fa3-4b77-b166-acb36f7f6042
Policy Category Kubernetes
Policy Description This policy controls the user, primary group, supplemental group and file system group IDs that pods and containers can use to run 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 True
Policy Deprecated FALSE
Policy Effect Default: audit
Allowed: (audit,deny,disabled)
Roles used none
Policy Changes
Date/Time (UTC ymd) (i) Change Change detail
2020-07-08 14:28:08 add: Policy f06ddb64-5fa3-4b77-b166-acb36f7f6042
Used in Policy Initiative(s)
Initiative DisplayName Initiative Id
[Preview]: Kubernetes cluster pod security restricted standards for Linux-based workloads 42b8ef37-b724-4e24-bbc8-7a7708edfe00
Policy Rule
{
  "properties": {
  "displayName": "[Preview]: Kubernetes cluster pods and containers should only run with approved user and group IDs",
    "policyType": "BuiltIn",
    "mode": "Microsoft.Kubernetes.Data",
    "description": "This policy controls the user, primary group, supplemental group and file system group IDs that pods and containers can use to run in a Kubernetes Cluster. For instructions on using this policy, visit https://aka.ms/kubepolicydoc.",
    "metadata": {
      "version": "1.0.0-preview",
      "category": "Kubernetes",
      "preview": true
    },
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
        "displayName": "[Preview]: 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": "[Preview]: Namespace exclusions",
          "description": "List of Kubernetes namespaces to exclude from policy evaluation."
        },
        "defaultValue": [
          "kube-system",
          "gatekeeper-system",
          "azure-arc"
        ]
      },
      "runAsUserRule": {
        "type": "String",
        "metadata": {
        "displayName": "[Preview]: Run as user rule",
          "description": "The 'RunAsUser' rule that containers are allowed to run with."
        },
        "allowedValues": [
          "MustRunAs",
          "MustRunAsNonRoot",
          "RunAsAny"
        ],
        "defaultValue": "MustRunAsNonRoot"
      },
      "runAsUserRanges": {
        "type": "Object",
        "metadata": {
        "displayName": "[Preview]: Allowed user ID ranges",
          "description": "The user ID ranges that are allowed for containers to use.",
          "schema": {
            "type": "object",
            "properties": {
              "ranges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "min": {
                      "type": "integer"
                    },
                    "max": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "min",
                    "max"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "ranges"
            ],
            "additionalProperties": false
          }
        },
        "defaultValue": {
          "ranges": [
            
          ]
        }
      },
      "runAsGroupRule": {
        "type": "String",
        "metadata": {
        "displayName": "[Preview]: Run as group rule",
          "description": "The 'RunAsGroup' rule that containers are allowed to run with."
        },
        "allowedValues": [
          "MustRunAs",
          "MayRunAs",
          "RunAsAny"
        ],
        "defaultValue": "RunAsAny"
      },
      "runAsGroupRanges": {
        "type": "Object",
        "metadata": {
        "displayName": "[Preview]: Allowed group ID ranges",
          "description": "The group ID ranges that are allowed for containers to use.",
          "schema": {
            "type": "object",
            "properties": {
              "ranges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "min": {
                      "type": "integer"
                    },
                    "max": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "min",
                    "max"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "ranges"
            ],
            "additionalProperties": false
          }
        },
        "defaultValue": {
          "ranges": [
            
          ]
        }
      },
      "supplementalGroupsRule": {
        "type": "String",
        "metadata": {
        "displayName": "[Preview]: Supplemental group rule",
          "description": "The 'SupplementalGroups' rule that containers are allowed to run with."
        },
        "allowedValues": [
          "MustRunAs",
          "MayRunAs",
          "RunAsAny"
        ],
        "defaultValue": "RunAsAny"
      },
      "supplementalGroupsRanges": {
        "type": "Object",
        "metadata": {
        "displayName": "[Preview]: Allowed supplemental group ID ranges",
          "description": "The supplemental group ID ranges that are allowed for containers to use.",
          "schema": {
            "type": "object",
            "properties": {
              "ranges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "min": {
                      "type": "integer"
                    },
                    "max": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "min",
                    "max"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "ranges"
            ],
            "additionalProperties": false
          }
        },
        "defaultValue": {
          "ranges": [
            
          ]
        }
      },
      "fsGroupRule": {
        "type": "String",
        "metadata": {
        "displayName": "[Preview]: File system group rule",
          "description": "The 'FSGroup' rule that containers are allowed to run with."
        },
        "allowedValues": [
          "MustRunAs",
          "MayRunAs",
          "RunAsAny"
        ],
        "defaultValue": "RunAsAny"
      },
      "fsGroupRanges": {
        "type": "Object",
        "metadata": {
        "displayName": "[Preview]: Allowed file system group ID ranges",
          "description": "The file system group ranges that are allowed for pods to use.",
          "schema": {
            "type": "object",
            "properties": {
              "ranges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "min": {
                      "type": "integer"
                    },
                    "max": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "min",
                    "max"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "ranges"
            ],
            "additionalProperties": false
          }
        },
        "defaultValue": {
          "ranges": [
            
          ]
        }
      }
    },
    "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/allowed-users-groups/template.yaml",
          "constraint": "https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-references/Kubernetes/allowed-users-groups/constraint.yaml",
          "values": {
            "runAsUser": {
            "rule": "[parameters('runAsUserRule')]",
            "ranges": "[parameters('runAsUserRanges').ranges]"
            },
            "runAsGroup": {
            "rule": "[parameters('runAsGroupRule')]",
            "ranges": "[parameters('runAsGroupRanges').ranges]"
            },
            "supplementalGroups": {
            "rule": "[parameters('supplementalGroupsRule')]",
            "ranges": "[parameters('supplementalGroupsRanges').ranges]"
            },
            "fsGroup": {
            "rule": "[parameters('fsGroupRule')]",
            "ranges": "[parameters('fsGroupRanges').ranges]"
            },
          "excludedNamespaces": "[parameters('excludedNamespaces')]"
          }
        }
      }
    }
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/f06ddb64-5fa3-4b77-b166-acb36f7f6042",
  "type": "Microsoft.Authorization/policyDefinitions",
  "name": "f06ddb64-5fa3-4b77-b166-acb36f7f6042"
}