Skip to content

Commit 27f9d9d

Browse files
authored
Merge pull request #177269 from nehakulkarni123/patch-1
Arc Policy Extension
2 parents 0855312 + 7bf22b8 commit 27f9d9d

File tree

1 file changed

+164
-11
lines changed

1 file changed

+164
-11
lines changed

articles/governance/policy/concepts/policy-for-kubernetes.md

Lines changed: 164 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ To enable and use Azure Policy with your Kubernetes cluster, take the following
4040

4141
1. Configure your Kubernetes cluster and install the add-on:
4242
- [Azure Kubernetes Service (AKS)](#install-azure-policy-add-on-for-aks)
43-
- [Azure Arc enabled Kubernetes](#install-azure-policy-add-on-for-azure-arc-enabled-kubernetes)
43+
- [Azure Arc enabled Kubernetes](#install-azure-policy-extension-for-azure-arc-enabled-kubernetes)
4444
- [AKS Engine](#install-azure-policy-add-on-for-aks-engine)
4545

4646
> [!NOTE]
@@ -71,7 +71,7 @@ The following general limitations apply to the Azure Policy Add-on for Kubernete
7171
available for the `Microsoft.Kubernetes.Data`
7272
[Resource Provider mode](./definition-structure.md#resource-provider-modes). Use
7373
[Component details](../how-to/determine-non-compliance.md#component-details-for-resource-provider-modes).
74-
- [Exemptions](./exemption-structure.md) aren't supported for
74+
- Component-level [exemptions](./exemption-structure.md) aren't supported for
7575
[Resource Provider modes](./definition-structure.md#resource-provider-modes).
7676

7777
The following limitations apply only to the Azure Policy Add-on for AKS:
@@ -126,14 +126,14 @@ must enable the **Microsoft.PolicyInsights** resource providers.
126126

127127
1. You need the Azure CLI version 2.12.0 or later installed and configured. Run `az --version` to
128128
find the version. If you need to install or upgrade, see
129-
[Install the Azure CLI](/cli/azure/install-azure-cli).
129+
[Install the Azure CLI](../../../azure-resource-manager/management/resource-providers-and-types.md#azure-cli).
130130

131131
1. Register the resource providers and preview features.
132132

133133
- Azure portal:
134134

135135
Register the **Microsoft.PolicyInsights** resource providers. For steps, see
136-
[Resource providers and types](../../../azure-resource-manager/management/resource-providers-and-types.md#azure-portal).
136+
[Resource providers and types](../../../azure-resource-manager/management/resource-providers-and-types.md#register-resource-provider).
137137

138138
- Azure CLI:
139139

@@ -158,7 +158,7 @@ must enable the **Microsoft.PolicyInsights** resource providers.
158158
```
159159

160160
1. Install version _2.12.0_ or higher of the Azure CLI. For more information, see
161-
[Install the Azure CLI](/cli/azure/install-azure-cli).
161+
[Install the Azure CLI](../../../azure-resource-manager/management/resource-providers-and-types.md#azure-cli).
162162

163163
Once the above prerequisite steps are completed, install the Azure Policy Add-on in the AKS cluster
164164
you want to manage.
@@ -205,16 +205,158 @@ similar to the following output:
205205
"identity": null
206206
}
207207
```
208+
## <a name="install-azure-policy-extension-for-azure-arc-enabled-kubernetes"></a>Install Azure Policy Extension for Azure Arc enabled Kubernetes (preview)
208209

209-
## <a name="install-azure-policy-add-on-for-azure-arc-enabled-kubernetes"></a>Install Azure Policy Add-on for Azure Arc enabled Kubernetes (preview)
210+
[Azure Policy for Kubernetes](./policy-for-kubernetes.md) makes it possible to manage and report on the compliance state of your Kubernetes clusters from one place.
211+
212+
This article describes how to [create](#create-azure-policy-extension), [show extension status](#show-azure-policy-extension), and [delete](#delete-azure-policy-extension) the Azure Policy for Kubernetes extension.
213+
214+
For an overview of the extensions platform, see [Azure Arc cluster extensions](/azure/azure-arc/kubernetes/conceptual-extensions).
215+
216+
### Prerequisites
217+
218+
> Note: If you have already deployed Azure Policy for Kubernetes on an Azure Arc cluster using Helm directly without extensions, follow the instructions listed to [delete the Helm chart](#remove-the-add-on-from-azure-arc-enabled-kubernetes). Once the deletion is done, you can then proceed.
219+
1. Ensure your Kubernetes cluster is a supported distribution.
220+
221+
> Note: Azure Policy for Arc extension is supported on [the following Kubernetes distributions](/azure-arc/kubernetes/conceptual-extensions).
222+
1. Ensure you have met all the common prerequisites for Kubernetes extensions listed [here](/azure/azure-arc/kubernetes/extensions) including [connecting your cluster to Azure Arc](/azure/azure-arc/kubernetes/quickstart-connect-cluster?tabs=azure-cli).
223+
224+
> Note: Azure Policy extension is supported for Arc enabled Kubernetes clusters [in these regions](https://azure.microsoft.com/global-infrastructure/services/?products=azure-arc).
225+
1. Open ports for the Azure Policy extension. The Azure Policy extension uses these domains and ports to fetch policy
226+
definitions and assignments and report compliance of the cluster back to Azure Policy.
227+
228+
|Domain |Port |
229+
|---|---|
230+
|`data.policy.core.windows.net` |`443` |
231+
|`store.policy.core.windows.net` |`443` |
232+
|`login.windows.net` |`443` |
233+
|`dc.services.visualstudio.com` |`443` |
234+
235+
1. Before installing the Azure Policy extension or enabling any of the service features, your subscription must enable the **Microsoft.PolicyInsights** resource providers.
236+
> Note: To enable the resource provider, follow the steps in
237+
[Resource providers and types](/azure/azure-resource-manager/management/resource-providers-and-types#azure-portal)
238+
or run either the Azure CLI or Azure PowerShell command:
239+
- Azure CLI
240+
241+
```azurecli-interactive
242+
# Log in first with az login if you're not using Cloud Shell
243+
# Provider register: Register the Azure Policy provider
244+
az provider register --namespace 'Microsoft.PolicyInsights'
245+
```
246+
247+
- Azure PowerShell
248+
249+
```azurepowershell-interactive
250+
# Log in first with Connect-AzAccount if you're not using Cloud Shell
251+
252+
# Provider register: Register the Azure Policy provider
253+
Register-AzResourceProvider -ProviderNamespace 'Microsoft.PolicyInsights'
254+
```
255+
256+
### Create Azure Policy extension
257+
258+
> Note the following for Azure Policy extension creation:
259+
> - Auto-upgrade is enabled by default which will update Azure Policy extension minor version if any new changes are deployed.
260+
> - Any proxy variables passed as parameters to `connectedk8s` will be propagated to the Azure Policy extension to support outbound proxy.
261+
>
262+
To create an extension instance, for your Arc enabled cluster, run the following command substituting `<>` with your values:
263+
264+
```console
265+
az k8s-extension create --cluster-type connectedClusters --cluster-name <CLUSTER_NAME> --resource-group <RESOURCE_GROUP> --extension-type Microsoft.PolicyInsights --name <EXTENSION_INSTANCE_NAME>
266+
```
267+
268+
#### Example:
269+
270+
```console
271+
az k8s-extension create --cluster-type connectedClusters --cluster-name my-test-cluster --resource-group my-test-rg --extension-type Microsoft.PolicyInsights --name azurepolicy
272+
```
273+
274+
#### Example Output:
275+
276+
```
277+
{
278+
"aksAssignedIdentity": null,
279+
"autoUpgradeMinorVersion": true,
280+
"configurationProtectedSettings": {},
281+
"configurationSettings": {},
282+
"customLocationSettings": null,
283+
"errorInfo": null,
284+
"extensionType": "microsoft.policyinsights",
285+
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/my-test-rg/providers/Microsoft.Kubernetes/connectedClusters/my-test-cluster/providers/Microsoft.KubernetesConfiguration/extensions/azurepolicy",
286+
"identity": {
287+
"principalId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
288+
"tenantId": null,
289+
"type": "SystemAssigned"
290+
},
291+
"location": null,
292+
"name": "azurepolicy",
293+
"packageUri": null,
294+
"provisioningState": "Succeeded",
295+
"releaseTrain": "Stable",
296+
"resourceGroup": "my-test-rg",
297+
"scope": {
298+
"cluster": {
299+
"releaseNamespace": "kube-system"
300+
},
301+
"namespace": null
302+
},
303+
"statuses": [],
304+
"systemData": {
305+
"createdAt": "2021-10-27T01:20:06.834236+00:00",
306+
"createdBy": null,
307+
"createdByType": null,
308+
"lastModifiedAt": "2021-10-27T01:20:06.834236+00:00",
309+
"lastModifiedBy": null,
310+
"lastModifiedByType": null
311+
},
312+
"type": "Microsoft.KubernetesConfiguration/extensions",
313+
"version": "1.1.0"
314+
}
315+
```
316+
317+
### Show Azure Policy extension
318+
319+
To check the extension instance creation was successful, and inspect extension metadata, run the following command substituting `<>` with your values:
320+
321+
```console
322+
az k8s-extension show --cluster-type connectedClusters --cluster-name <CLUSTER_NAME> --resource-group <RESOURCE_GROUP> --name <EXTENSION_INSTANCE_NAME>
323+
```
324+
325+
#### Example:
326+
327+
```console
328+
az k8s-extension show --cluster-type connectedClusters --cluster-name my-test-cluster --resource-group my-test-rg --name azurepolicy
329+
```
330+
331+
#### To validate that the add-on installation was successful and that the azure-policy and gatekeeper pods are running, run the following command:
332+
333+
```console
334+
kubectl get pods -n kube-system
335+
```
336+
337+
```console
338+
kubectl get pods -n gatekeeper-system
339+
```
340+
341+
### Delete Azure Policy extension
342+
To delete the extension instance, run the following command substituting `<>` with your values:
343+
344+
```console
345+
az k8s-extension delete --cluster-type connectedClusters --cluster-name <CLUSTER_NAME> --resource-group <RESOURCE_GROUP> --name <EXTENSION_INSTANCE_NAME>
346+
```
347+
348+
## <a name="install-azure-policy-add-on-for-azure-arc-enabled-kubernetes"></a>Install Azure Policy Add-on Using Helm for Azure Arc enabled Kubernetes (preview)
349+
350+
> [!NOTE]
351+
> Azure Policy Add-on Helm model will soon begin deprecation. Please opt for the [Azure Policy Extension for Azure Arc enabled Kubernetes](#install-azure-policy-extension-for-azure-arc-enabled-kubernetes) instead.
210352
211353
Before installing the Azure Policy Add-on or enabling any of the service features, your subscription
212354
must enable the **Microsoft.PolicyInsights** resource provider and create a role assignment for the
213355
cluster service principal.
214356

215357
1. You need the Azure CLI version 2.12.0 or later installed and configured. Run `az --version` to
216358
find the version. If you need to install or upgrade, see
217-
[Install the Azure CLI](/cli/azure/install-azure-cli).
359+
[Install the Azure CLI](../../../azure-resource-manager/management/resource-providers-and-types.md#azure-cli).
218360

219361
1. To enable the resource provider, follow the steps in
220362
[Resource providers and types](../../../azure-resource-manager/management/resource-providers-and-types.md#azure-portal)
@@ -328,12 +470,16 @@ kubectl get pods -n gatekeeper-system
328470

329471
## <a name="install-azure-policy-add-on-for-aks-engine"></a>Install Azure Policy Add-on for AKS Engine (preview)
330472

473+
> Note: Azure Policy Add-on for AKS Engine is soon to begin deprecation. We recommend that you install the [Azure Policy Extension using Arc-enabled Kubernetes](#install-azure-policy-extension-for-azure-arc-enabled-kubernetes) instead.
474+
475+
1. Ensure your Kubernetes cluster is a supported distribution.
476+
331477
Before installing the Azure Policy Add-on or enabling any of the service features, your subscription
332478
must enable the **Microsoft.PolicyInsights** resource provider and create a role assignment for the
333479
cluster service principal.
334480

335481
1. You need the Azure CLI version 2.0.62 or later installed and configured. Run `az --version` to
336-
find the version. If you need to install or upgrade, see [Install the Azure CLI](/cli/azure/install-azure-cli).
482+
find the version. If you need to install or upgrade, see [Install the Azure CLI](../../../azure-resource-manager/management/resource-providers-and-types.md#azure-cli).
337483

338484
1. To enable the resource provider, follow the steps in
339485
[Resource providers and types](../../../azure-resource-manager/management/resource-providers-and-types.md#azure-portal)
@@ -649,7 +795,7 @@ Constraint templates that start with `k8sazure` are the ones installed by the ad
649795
### Get Azure Policy mappings
650796
651797
To identify the mapping between a constraint template downloaded to the cluster and the policy
652-
definition, use `kubectl get constrainttemplates <TEMPLATE> -o yaml`. The results look similiar to
798+
definition, use `kubectl get constrainttemplates <TEMPLATE> -o yaml`. The results look similar to
653799
the following output:
654800
655801
```yaml
@@ -677,13 +823,13 @@ install on the cluster.
677823
Once you have the names of the
678824
[add-on downloaded constraint templates](#view-the-add-on-constraint-templates), you can use the
679825
name to see the related constraints. Use `kubectl get <constraintTemplateName>` to get the list.
680-
Constraints installed by the add-on start wtih `azurepolicy-`.
826+
Constraints installed by the add-on start with `azurepolicy-`.
681827
682828
### View constraint details
683829
684830
The constraint has details about violations and mappings to the policy definition and assignment. To
685831
see the details, use `kubectl get <CONSTRAINT-TEMPLATE> <CONSTRAINT> -o yaml`. The results look
686-
similiar to the following output:
832+
similar to the following output:
687833
688834
```yaml
689835
apiVersion: constraints.gatekeeper.sh/v1beta1
@@ -727,6 +873,13 @@ For more information about troubleshooting the Add-on for Kubernetes, see the
727873
[Kubernetes section](../troubleshoot/general.md#add-on-for-kubernetes-general-errors)
728874
of the Azure Policy troubleshooting article.
729875
876+
For Azure Policy extension for Arc extension related issues, please see:
877+
- [Azure Arc enabled Kubernetes troubleshooting](/azure/azure-arc/kubernetes/troubleshooting#azure-arc-enabled-kubernetes-troubleshooting)
878+
879+
For Azure Policy related issues, please see:
880+
- [Inspect Azure Policy logs](/azure/governance/policy/concepts/policy-for-kubernetes#logging)
881+
- [General troubleshooting for Azure Policy on Kubernetes](/azure/governance/policy/troubleshoot/general#add-on-for-kubernetes-general-errors)
882+
730883
## Remove the add-on
731884
732885
### Remove the add-on from AKS

0 commit comments

Comments
 (0)