Skip to content

Commit ecc42d2

Browse files
authored
Merge pull request #109597 from DCtheGeek/dmc-policy-aksrb
AKS rollback
2 parents 8058148 + 8cfca90 commit ecc42d2

File tree

2 files changed

+85
-105
lines changed

2 files changed

+85
-105
lines changed

articles/governance/policy/concepts/effects.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -533,16 +533,17 @@ not, then a deployment to enable is executed.
533533
This effect is used with a policy definition *mode* of `Microsoft.Kubernetes.Data`. It's used to
534534
pass Gatekeeper v3 admission control rules defined with
535535
[OPA Constraint Framework](https://github.com/open-policy-agent/frameworks/tree/master/constraint#opa-constraint-framework)
536-
to [Open Policy Agent](https://www.openpolicyagent.org/) (OPA) to Kubernetes clusters on Azure.
536+
to [Open Policy Agent](https://www.openpolicyagent.org/) (OPA) to self-managed Kubernetes clusters
537+
on Azure.
537538

538539
> [!NOTE]
539-
> [Azure Policy for Kubernetes](aks-engine.md) is in Preview and only supports built-in policy
540-
> definitions.
540+
> [Azure Policy for AKS Engine](aks-engine.md) is in Public Preview and only supports built-in
541+
> policy definitions.
541542
542543
### EnforceOPAConstraint evaluation
543544

544545
The Open Policy Agent admission controller evaluates any new request on the cluster in real time.
545-
Every 15 minutes, a full scan of the cluster is completed and the results reported to Azure Policy.
546+
Every 5 minutes, a full scan of the cluster is completed and the results reported to Azure Policy.
546547

547548
### EnforceOPAConstraint properties
548549

@@ -563,8 +564,8 @@ Gatekeeper v3 admission control rule.
563564

564565
### EnforceOPAConstraint example
565566

566-
Example: Gatekeeper v3 admission control rule to set container CPU and memory resource limits in
567-
Kubernetes.
567+
Example: Gatekeeper v3 admission control rule to set container CPU and memory resource limits in AKS
568+
Engine.
568569

569570
```json
570571
"if": {
@@ -603,11 +604,9 @@ to pass Gatekeeper v2 admission control rules defined with
603604
[Open Policy Agent](https://www.openpolicyagent.org/) (OPA) on
604605
[Azure Kubernetes Service](../../../aks/intro-kubernetes.md).
605606

606-
> [!IMPORTANT]
607-
> [Azure Policy for Kubernetes](rego-for-aks.md) is in Preview and only supports built-in policy
608-
> definitions. Built-in policies are in the **Kubernetes** category. The **EnforceRegoPolicy**
609-
> effect and related **Kubernetes Service** category policies are being _deprecated_. Instead, use
610-
> the updated [EnforceOPAConstraint](#enforceopaconstraint) effect.
607+
> [!NOTE]
608+
> [Azure Policy for AKS](rego-for-aks.md) is in Limited Preview and only supports built-in policy
609+
> definitions
611610
612611
### EnforceRegoPolicy evaluation
613612

articles/governance/policy/concepts/rego-for-aks.md

Lines changed: 75 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
---
22
title: Learn Azure Policy for Azure Kubernetes Service
3-
description: Learn how Azure Policy uses Rego and Open Policy Agent to manage clusters on Azure Kubernetes Service.
4-
ms.date: 03/27/2020
3+
description: Learn how Azure Policy uses Rego and Open Policy Agent to manage clusters on Azure Kubernetes Service.
4+
ms.date: 03/18/2020
55
ms.topic: conceptual
66
---
77
# Understand Azure Policy for Azure Kubernetes Service
88

99
Azure Policy integrates with the [Azure Kubernetes Service](../../../aks/intro-kubernetes.md) (AKS)
1010
to apply at-scale enforcements and safeguards on your clusters in a centralized, consistent manner.
11-
By extending use of [Gatekeeper](https://github.com/open-policy-agent/gatekeeper) v3, an _admission
12-
controller webhook_ for [Open Policy Agent](https://www.openpolicyagent.org/) (OPA), Azure Policy
13-
makes it possible to manage and report on the compliance state of your Azure resources and AKS
14-
clusters from one place.
11+
By extending use of
12+
[Gatekeeper](https://github.com/open-policy-agent/gatekeeper/tree/master/deprecated) v2, an
13+
_admission controller webhook_ for [Open Policy Agent](https://www.openpolicyagent.org/) (OPA),
14+
Azure Policy makes it possible to manage and report on the compliance state of your Azure resources
15+
and AKS clusters from one place.
1516

16-
> [!IMPORTANT]
17-
> Azure Policy for AKS is in Preview and only supports built-in policy definitions. Built-in
18-
> policies are in the **Kubernetes** category. The **EnforceRegoPolicy** effect and related
19-
> **Kubernetes Service** category policies are being _deprecated_. Instead, use the updated
20-
> [EnforceOPAConstraint](./effects.md#enforceopaconstraint) effect.
21-
22-
> [!WARNING]
23-
> This feature isn't yet available in all regions. For a status on the rollout, see
24-
> [AKS Issues - Breaking Change for Policy Add-on](https://github.com/Azure/AKS/issues/1529).
17+
> [!NOTE]
18+
> Azure Policy for AKS is in Limited Preview and only supports built-in policy definitions.
2519
2620
## Overview
2721

@@ -34,9 +28,9 @@ To enable and use Azure Policy for AKS with your AKS cluster, take the following
3428

3529
## Opt-in for preview
3630

37-
Before you install the Azure Policy Add-on or enabling any of the service features, your
38-
subscription must enable the **Microsoft.ContainerService** resource provider and the
39-
**Microsoft.PolicyInsights** resource provider, then get approved to join the preview. To join the
31+
Before installing the Azure Policy Add-on or enabling any of the service features, your subscription
32+
must enable the **Microsoft.ContainerService** resource provider and the
33+
**Microsoft.PolicyInsights** resource provider, then be approved to join the preview. To join the
4034
preview, follow these steps in either the Azure portal or with Azure CLI:
4135

4236
- Azure portal:
@@ -63,7 +57,7 @@ preview, follow these steps in either the Azure portal or with Azure CLI:
6357
```azurecli-interactive
6458
# Log in first with az login if you're not using Cloud Shell
6559
66-
# Provider register: Register the Azure Kubernetes Service provider
60+
# Provider register: Register the Azure Kubernetes Services provider
6761
az provider register --namespace Microsoft.ContainerService
6862
6963
# Provider register: Register the Azure Policy provider
@@ -78,19 +72,27 @@ preview, follow these steps in either the Azure portal or with Azure CLI:
7872
# Once the above shows 'Registered' run the following to propagate the update
7973
az provider register -n Microsoft.ContainerService
8074
75+
# Feature register: enables the add-on to call the Azure Policy resource provider
76+
az feature register --namespace Microsoft.PolicyInsights --name AKS-DataPlaneAutoApprove
77+
78+
# Use the following to confirm the feature has registered
79+
az feature list -o table --query "[?contains(name, 'Microsoft.PolicyInsights/AKS-DataPlaneAutoApprove')].{Name:name,State:properties.state}"
80+
81+
# Once the above shows 'Registered' run the following to propagate the update
82+
az provider register -n Microsoft.PolicyInsights
83+
8184
```
8285

8386
## Azure Policy Add-on
8487

8588
The _Azure Policy Add-on_ for Kubernetes connects the Azure Policy service to the Gatekeeper
86-
admission controller. The add-on, which is installed into the _kube-system_ namespace, enacts the
89+
admission controller. The add-on, which is installed into the _azure-policy_ namespace, enacts the
8790
following functions:
8891

89-
- Checks with Azure Policy service for assignments to the cluster.
90-
- Deploys policies in the cluster as
91-
[constraint template](https://github.com/open-policy-agent/gatekeeper#constraint-templates) and
92-
[constraint](https://github.com/open-policy-agent/gatekeeper#constraints) custom resources.
93-
- Reports auditing and compliance details back to Azure Policy service.
92+
- Checks with Azure Policy for assignments to the AKS cluster
93+
- Downloads and caches policy details, including the _rego_ policy definition, as **configmaps**
94+
- Runs a full scan compliance check on the AKS cluster
95+
- Reports auditing and compliance details back to Azure Policy
9496

9597
### Installing the add-on
9698

@@ -99,13 +101,10 @@ following functions:
99101
Before you install the add-on in your AKS cluster, the preview extension must be installed. This
100102
step is done with Azure CLI:
101103

102-
1. If Gatekeeper v2 policies were installed, remove the add-on with the **Disable** button on your
103-
AKS cluster under the **Policies (preview)** page.
104-
105104
1. You need the Azure CLI version 2.0.62 or later installed and configured. Run `az --version` to
106105
find the version. If you need to install or upgrade, see [Install the Azure CLI](/cli/azure/install-azure-cli).
107106

108-
1. The AKS cluster must be version _1.14_ or higher. Use the following script to validate your AKS
107+
1. The AKS cluster must be version _1.10_ or higher. Use the following script to validate your AKS
109108
cluster version:
110109

111110
```azurecli-interactive
@@ -153,8 +152,7 @@ manage.
153152

154153
> [!NOTE]
155154
> If the **Enable add-on** button is grayed out, the subscription has not yet been added to the
156-
> preview. See [Opt-in for preview](#opt-in-for-preview) for the required steps. If a
157-
> **Disable** button is available, Gatekeeper v2 is still installed and must be removed.
155+
> preview. See [Opt-in for preview](#opt-in-for-preview) for the required steps.
158156
159157
- Azure CLI
160158

@@ -166,98 +164,81 @@ manage.
166164

167165
### Validation and reporting frequency
168166

169-
The add-on checks in with Azure Policy service for changes in policy assignments every 15 minutes.
170-
During this refresh cycle, the add-on checks for changes. These changes trigger creates, updates, or
171-
deletes of the constraint templates and constraints.
167+
The add-on checks in with Azure Policy for changes in policy assignments every 5 minutes. During
168+
this refresh cycle, the add-on removes all _configmaps_ in the _azure-policy_ namespace then
169+
recreates the _configmaps_ for Gatekeeper use.
172170

173171
> [!NOTE]
174-
> While a cluster admin may have permission to create and update constraint templates and
175-
> constraints resources, these are not supported scenarios as manual updates will be overwritten.
172+
> While a _cluster admin_ may have permission to the _azure-policy_ namespace, it's not recommended
173+
> or supported to make changes to the namespace. Any manual changes made are lost during the
174+
> refresh cycle.
176175
177-
Every 15 minutes, the add-on calls for a full scan of the cluster. After gathering details of the
176+
Every 5 minutes, the add-on calls for a full scan of the cluster. After gathering details of the
178177
full scan and any real-time evaluations by Gatekeeper of attempted changes to the cluster, the
179-
add-on reports the results back to Azure Policy service for inclusion in
180-
[compliance details](../how-to/get-compliance-data.md#portal) like any Azure Policy assignment. Only
181-
results for active policy assignments are returned during the audit cycle. Audit results can also be
182-
seen as [violations](https://github.com/open-policy-agent/gatekeeper#audit) listed in the status
183-
field of the failed constraint.
178+
add-on reports the results back to Azure Policy for inclusion in
179+
[compliance details](../how-to/get-compliance-data.md) like any Azure Policy assignment. Only
180+
results for active policy assignments are returned during the audit cycle.
184181

185182
## Policy language
186183

187-
The Azure Policy language structure for managing Kubernetes follows that of existing policies. The
188-
effect _EnforceOPAConstraint_ is used to manage your Kubernetes clusters and takes details
189-
properties specific to working with
190-
[OPA Constraint Framework](https://github.com/open-policy-agent/frameworks/tree/master/constraint)
191-
and Gatekeeper v3. For details and examples, see the
192-
[EnforceOPAConstraint](./effects.md#enforceopaconstraint) effect.
193-
194-
As part of the _details.constraintTemplate_ and _details.constraint_ properties in the policy
195-
definition, Azure Policy passes the URIs of these
196-
[CustomResourceDefinitions](https://github.com/open-policy-agent/gatekeeper#constraint-templates)
197-
(CRD) to the add-on. Rego is the language that OPA and Gatekeeper support to validate a request to
198-
the Kubernetes cluster. By supporting an existing standard for Kubernetes management, Azure Policy
199-
makes it possible to reuse existing rules and pair them with Azure Policy for a unified cloud
200-
compliance reporting experience. For more information, see
184+
The Azure Policy language structure for managing AKS follows that of existing policies. The effect
185+
_EnforceRegoPolicy_ is used to manage your AKS clusters and takes _details_ properties specific to
186+
working with OPA and Gatekeeper v2. For details and examples, see the
187+
[EnforceRegoPolicy](effects.md#enforceregopolicy) effect.
188+
189+
As part of the _details.policy_ property in the policy definition, Azure Policy passes the URI of a
190+
rego policy to the add-on. Rego is the language that OPA and Gatekeeper support to validate or
191+
mutate a request to the Kubernetes cluster. By supporting an existing standard for Kubernetes
192+
management, Azure Policy makes it possible to reuse existing rules and pair them with Azure Policy
193+
for a unified cloud compliance reporting experience. For more information, see
201194
[What is Rego?](https://www.openpolicyagent.org/docs/latest/policy-language/#what-is-rego).
202195

203196
## Built-in policies
204197

205-
To find the built-in policies for managing your cluster using the Azure portal, follow these steps:
198+
To find the built-in policies for managing AKS using the Azure portal, follow these steps:
206199

207-
1. Start the Azure Policy service in the Azure portal. Select All services in the left pane and then
208-
search for and select **Policy**.
200+
1. Start the Azure Policy service in the Azure portal. Select **All services** in the left pane and
201+
then search for and select **Policy**.
209202

210203
1. In the left pane of the Azure Policy page, select **Definitions**.
211204

212-
1. From the Category drop-down list box, use Select all to clear the filter and then select
213-
**Kubernetes**.
205+
1. From the Category drop-down list box, use **Select all** to clear the filter and then select
206+
**Kubernetes service**.
214207

215208
1. Select the policy definition, then select the **Assign** button.
216209

217-
1. Set the **Scope** to the management group, subscription, or resource group of the Kubernetes
218-
cluster where the policy assignment will apply.
219-
220-
> [!NOTE]
221-
> When assigning the Azure Policy for AKS definition, the **Scope** must include the AKS cluster
222-
> resource.
223-
224-
1. Give the policy assignment a **Name** and **Description** that you can use to identify it easily.
225-
226-
1. Set the [Policy enforcement](./assignment-structure.md#enforcement-mode) to one of the values
227-
below.
228-
229-
- **Enabled** - Enforce the policy on the cluster. Kubernetes admission requests with violations
230-
are denied.
231-
232-
- **Disabled** - Don't enforce the policy on the cluster. Kubernetes admission requests with
233-
violations aren't denied. Compliance assessment results are still available. When rolling out
234-
new policies to running clusters, _Disabled_ option is helpful for testing the policies as
235-
admission requests with violations aren't denied.
236-
237-
1. Select **Next**.
238-
239-
1. Set **parameter values**
240-
241-
- To exclude Kubernetes namespaces from policy evaluation, specify the list of namespaces in
242-
parameter **Namespace exclusions**. It's recommended to exclude: _kube-system_
243-
244-
1. Select **Review + create**.
210+
> [!NOTE]
211+
> When assigning the Azure Policy for AKS definition, the **Scope** must include the AKS cluster
212+
> resource.
245213
246214
Alternately, use the [Assign a policy - Portal](../assign-policy-portal.md) quickstart to find and
247215
assign an AKS policy. Search for a Kubernetes policy definition instead of the sample 'audit vms'.
248216

249217
> [!IMPORTANT]
250-
> Built-in policies in category **Kubernetes** are only for use with AKS. For a list of built-in
251-
> policies, see [Kubernetes samples](../samples/built-in-policies.md#kubernetes).
218+
> Built-in policies in category **Kubernetes service** are only for use with AKS.
252219
253220
## Logging
254221

255222
### Azure Policy Add-on logs
256223

257-
As a Kubernetes controller/container, both Azure Policy Add-on and Gatekeeper keep logs in the AKS
258-
cluster. The logs are exposed in the **Insights** page of the AKS cluster. For more information, see
224+
As a Kubernetes controller/container, the Azure Policy Add-on keeps logs in the AKS cluster. The
225+
logs are exposed in the **Insights** page of the AKS cluster. For more information, see
259226
[Understand AKS cluster performance with Azure Monitor for containers](../../../azure-monitor/insights/container-insights-analyze.md).
260227

228+
### Gatekeeper logs
229+
230+
To enable Gatekeeper logs for new resource requests, follow the steps in [Enable and review Kubernetes master node logs in AKS](../../../aks/view-master-logs.md).
231+
Here is an example query to view denied events on new resource requests:
232+
233+
```kusto
234+
| where Category == "kube-audit"
235+
| where log_s contains "admission webhook"
236+
| limit 100
237+
```
238+
239+
To view logs from Gatekeeper containers, follow the steps in [Enable and review Kubernetes master node logs in AKS](../../../aks/view-master-logs.md)
240+
and check the _kube-apiserver_ option in the **Diagnostic settings** pane.
241+
261242
## Remove the add-on
262243

263244
To remove the Azure Policy Add-on from your AKS cluster, use either the Azure portal or Azure CLI:
@@ -319,4 +300,4 @@ collected:
319300
- Understand how to [programmatically create policies](../how-to/programmatically-create.md).
320301
- Learn how to [get compliance data](../how-to/get-compliance-data.md).
321302
- Learn how to [remediate non-compliant resources](../how-to/remediate-resources.md).
322-
- Review what a management group is with [Organize your resources with Azure management groups](../../management-groups/overview.md).
303+
- Review what a management group is with [Organize your resources with Azure management groups](../../management-groups/overview.md).

0 commit comments

Comments
 (0)