Instruire
Modul
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.
Acest browser nu mai este acceptat.
Faceți upgrade la Microsoft Edge pentru a profita de cele mai noi funcții, actualizări de securitate și asistență tehnică.
The audit
effect is used to create a warning event in the activity log when evaluating a non-compliant resource, but it doesn't stop the request.
Audit is the last effect checked by Azure Policy during the creation or update of a resource. For a Resource Manager mode, Azure Policy then sends the resource to the Resource Provider. When evaluating a create or update request for a resource, Azure Policy adds a Microsoft.Authorization/policies/audit/action
operation to the activity log and marks the resource as non-compliant. During a standard compliance evaluation cycle, only the compliance status on the resource is updated.
For a Resource Manager mode, the audit effect doesn't have any other properties for use in the then
condition of the policy definition.
For a Resource Provider mode of Microsoft.Kubernetes.Data
, the audit 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.
Avertisment
Don't use SAS URIs, URL tokens, or anything else that could expose secrets in plain text.
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
(deprecated)
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
, kinds
, scope
, namespaces
, excludedNamespaces
, or labelSelector
.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.
Avertisment
Don't use SAS URIs or tokens in url
or anything else that could expose a secret.
namespaces
(optional)
excludedNamespaces
(optional)
labelSelector
(optional)
scope
(optional)
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)
openAPIV3Schema
section of the Constraint template CRD.Example 1: Using the audit effect for Resource Manager modes.
"then": {
"effect": "audit"
}
Example 2: Using the audit 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": "audit",
"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"
]
}
}
Instruire
Modul
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.