Koolitus
Moodul
Azure Kubernetes Services Governance with Azure Policy - Training
In this module, we discuss how to use Azure Policy for Kubernetes to enforce rules and detect noncompliance in AKS clusters.
Seda brauserit enam ei toetata.
Uusimate funktsioonide, turbevärskenduste ja tehnilise toe kasutamiseks võtke kasutusele Microsoft Edge.
The deny
effect is used to prevent a resource request that doesn't match defined standards through a policy definition and fails the request.
When creating or updating a matched resource in a Resource Manager mode, deny prevents the request before being sent to the Resource Provider. The request is returned as a 403 (Forbidden)
. In the portal, the Forbidden
can be viewed as a deployment status that was prevented by the policy assignment. For a Resource Provider mode, the resource provider manages the evaluation of the resource.
During evaluation of existing resources, resources that match a deny
policy definition are marked as non-compliant.
For a Resource Manager mode, the deny
effect doesn't have any more properties for use in the then
condition of the policy definition.
For a Resource Provider mode of Microsoft.Kubernetes.Data
, the deny
effect has the following subproperties of details
. Use of templateInfo
is required for new or updated policy definitions as constraintTemplate
is deprecated.
templateInfo
(required)
constraintTemplate
.sourceType
(required)
Defines the type of source for the constraint template. Allowed values: PublicURL
or Base64Encoded
.
If PublicURL
, paired with property url
to provide location of the constraint template. The location must be publicly accessible.
Hoiatus
Don't use SAS URIs or tokens in url
or anything else that could expose a secret.
If Base64Encoded
, paired with property content
to provide the base 64 encoded constraint template. See Create policy definition from constraint template to create a custom definition from an existing Open Policy Agent (OPA) Gatekeeper v3 constraint template.
constraint
(optional)
templateInfo
.values
as {{ .Values.<valuename> }}
. In example 2 below, these values are {{ .Values.excludedNamespaces }}
and {{ .Values.allowedContainerImagesRegex }}
.constraintTemplate
(deprecated)
templateInfo
.templateInfo
when creating or updating a policy definition.values
from Azure Policy. For more information, go to Gatekeeper constraints.constraintInfo
(optional)
constraint
, constraintTemplate
, apiGroups
, or kinds
.constraintInfo
isn't provided, the constraint can be generated from templateInfo
and policy.sourceType
(required)
Defines the type of source for the constraint. Allowed values: PublicURL
or Base64Encoded
.
If PublicURL
, paired with property url
to provide location of the constraint. The location must be publicly accessible.
Hoiatus
Don't use SAS URIs or tokens in url
or anything else that could expose a secret.
namespaces
(optional)
excludedNamespaces
.excludedNamespaces
(required)
labelSelector
(required)
matchLabels
(object) and matchExpression
(array) properties to allow specifying which Kubernetes resources to include for policy evaluation that matched the provided labels and selectors.excludedNamespaces
.apiGroups
(required when using templateInfo)
[""]
) is the core API group.["*"]
for apiGroups is disallowed.kinds
(required when using templateInfo)
["*"]
for kinds is disallowed.values
(optional)
Example 1: Using the deny
effect for Resource Manager modes.
"then": {
"effect": "deny"
}
Example 2: Using the deny
effect for a Resource Provider mode of Microsoft.Kubernetes.Data
. The additional information in details.templateInfo
declares use of PublicURL
and sets url
to the location of the Constraint template to use in Kubernetes to limit the allowed container images.
"then": {
"effect": "deny",
"details": {
"templateInfo": {
"sourceType": "PublicURL",
"url": "https://store.policy.core.windows.net/kubernetes/container-allowed-images/v1/template.yaml",
},
"values": {
"imageRegex": "[parameters('allowedContainerImagesRegex')]"
},
"apiGroups": [
""
],
"kinds": [
"Pod"
]
}
}
Koolitus
Moodul
Azure Kubernetes Services Governance with Azure Policy - Training
In this module, we discuss how to use Azure Policy for Kubernetes to enforce rules and detect noncompliance in AKS clusters.
Dokumentatsioon
Azure Policy definitions audit effect - Azure Policy
Azure Policy definitions audit effect determines how compliance is managed and reported.
Azure Policy definitions disabled effect - Azure Policy
Azure Policy definitions disabled effect determines how compliance is managed and reported.
Azure Policy definitions append effect - Azure Policy
Azure Policy definitions append effect determines how compliance is managed and reported.