You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-arc/kubernetes/use-azure-policy-flux-2.md
+36-26Lines changed: 36 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: "Deploy applications consistently at scale using Flux v2 configurations and Azure Policy"
3
-
ms.date: 06/02/2023
3
+
ms.date: 12/13/2023
4
4
ms.topic: how-to
5
5
description: "Use Azure Policy to apply Flux v2 configurations at scale on Azure Arc-enabled Kubernetes or AKS clusters."
6
6
---
@@ -9,34 +9,38 @@ description: "Use Azure Policy to apply Flux v2 configurations at scale on Azure
9
9
10
10
You can use Azure Policy to apply Flux v2 configurations (`Microsoft.KubernetesConfiguration/fluxConfigurations` resource type) at scale on Azure Arc-enabled Kubernetes (`Microsoft.Kubernetes/connectedClusters`) or AKS (`Microsoft.ContainerService/managedClusters`) clusters.
11
11
12
-
To use Azure Policy, select a built-in policy definition and create a policy assignment. You can search for **flux** to find all of the Flux v2 policy definitions. When creating the policy assignment:
12
+
To use Azure Policy, select a built-in policy definition and create a policy assignment. When creating the policy assignment:
13
13
14
14
1. Set the scope for the assignment to all resource groups in a subscription or management group, or to specific resource groups.
15
15
2. Set the parameters for the Flux v2 configuration that will be created.
16
16
17
17
Once the assignment is created, the Azure Policy engine identifies all Azure Arc-enabled Kubernetes clusters located within the scope and applies the GitOps configuration to each cluster.
18
18
19
-
To enable separation of concerns, you can create multiple policy assignments, each with a different Flux v2 configuration pointing to a different source. For example, one git repository may be used by cluster admins and other repositories may be used by application teams.
19
+
To enable separation of concerns, you can create multiple policy assignments, each with a different Flux v2 configuration pointing to a different source. For example, one Git repository may be used by cluster admins and other repositories may be used by application teams.
20
20
21
-
> [!TIP]
22
-
> There are [built-in policy definitions](policy-reference.md) for these scenarios:
23
-
>
24
-
> * Flux extension install (required for all scenarios): `Configure installation of Flux extension on Kubernetes cluster`
25
-
> * Flux configuration using public Git repository (generally a test scenario): `Configure Kubernetes clusters with Flux v2 configuration using public Git repository`
26
-
> * Flux configuration using private Git repository with SSH auth: `Configure Kubernetes clusters with Flux v2 configuration using Git repository and SSH secrets`
27
-
> * Flux configuration using private Git repository with HTTPS auth: `Configure Kubernetes clusters with Flux v2 configuration using Git repository and HTTPS secrets`
28
-
> * Flux configuration using private Git repository with HTTPS CA cert auth: `Configure Kubernetes clusters with Flux v2 configuration using Git repository and HTTPS CA Certificate`
29
-
> * Flux configuration using private Git repository with local K8s secret: `Configure Kubernetes clusters with Flux v2 configuration using Git repository and local secrets`
30
-
> * Flux configuration using private Bucket source and KeyVault secrets: `Configure Kubernetes clusters with Flux v2 configuration using Bucket source and secrets in KeyVault`
31
-
> * Flux configuration using private Bucket source and local K8s secret: `Configure Kubernetes clusters with specified Flux v2 Bucket source using local secrets`
21
+
## Built-in policy definitions
22
+
23
+
The following [built-in policy definitions](policy-reference.md) provide support for these scenarios:
24
+
25
+
* Flux extension install (required for all scenarios): `Configure installation of Flux extension on Kubernetes cluster`
26
+
* Flux configuration using public Git repository (generally a test scenario): `Configure Kubernetes clusters with Flux v2 configuration using public Git repository`
27
+
* Flux configuration using private Git repository with SSH auth: `Configure Kubernetes clusters with Flux v2 configuration using Git repository and SSH secrets`
28
+
* Flux configuration using private Git repository with HTTPS auth: `Configure Kubernetes clusters with Flux v2 configuration using Git repository and HTTPS secrets`
29
+
* Flux configuration using private Git repository with HTTPS CA cert auth: `Configure Kubernetes clusters with Flux v2 configuration using Git repository and HTTPS CA Certificate`
30
+
* Flux configuration using private Git repository with local K8s secret: `Configure Kubernetes clusters with Flux v2 configuration using Git repository and local secrets`
31
+
* Flux configuration using private Bucket source and KeyVault secrets: `Configure Kubernetes clusters with Flux v2 configuration using Bucket source and secrets in KeyVault`
32
+
* Flux configuration using private Bucket source and local K8s secret: `Configure Kubernetes clusters with specified Flux v2 Bucket source using local secrets`
33
+
34
+
To find all of the Flux v2 policy definitions, search for **flux**.
32
35
33
36
## Prerequisites
34
37
35
-
Verify you have `Microsoft.Authorization/policyAssignments/write` permissions on the scope (subscription or resource group) where you'll create this policy assignment.
38
+
* One or more Arc-enabled Kubernetes clusters and/or AKS clusters.
39
+
*`Microsoft.Authorization/policyAssignments/write` permissions on the scope (subscription or resource group) where you'll create the policy assignments.
36
40
37
-
## Create a policy assignment
41
+
## Create a policy assignment to install the Flux exension
38
42
39
-
In order for a policy to apply Flux v2 configurations to a cluster, the Flux extension must be installed on each cluster. You can ensure this by assigning the **Configure installation of Flux extension on Kubernetes cluster** policy definition to the desired scope.
43
+
In order for a policy to apply Flux v2 configurations to a cluster, the Flux extension must first be installed on the cluster. To ensure that the extension is installed to each of your clusters, assign the **Configure installation of Flux extension on Kubernetes cluster** policy definition to the desired scope.
40
44
41
45
1. In the Azure portal, navigate to **Policy**.
42
46
1. In the **Authoring** section of the sidebar, select **Definitions**.
@@ -48,12 +52,14 @@ In order for a policy to apply Flux v2 configurations to a cluster, the Flux ext
48
52
1. Ensure **Policy enforcement** is set to **Enabled**.
49
53
1. Select **Review + create**, then select **Create**.
50
54
51
-
Next, return to the **Definitions** list to apply the configuration policy definition to the same scope.
55
+
## Create a policy assignment to apply Flux configurations
56
+
57
+
Next, return to the **Definitions** list (in the **Authoring** section of **Policy**) to apply the configuration policy definition to the same scope.
52
58
53
59
1. In the "Kubernetes" category, select the **Configure Kubernetes clusters with Flux v2 configuration using public Git repository**
54
-
built-in policy definition.
60
+
built-in policy definition, or another policy definition from the list above.
55
61
1. Select **Assign**.
56
-
1. Set the **Scope** to the same scope that you selected when assigning the first policy, including any exceptions.
62
+
1. Set the **Scope** to the same scope that you selected when assigning the first policy, including any exclusions.
57
63
1. Give the policy assignment an easily identifiable **Assignment name** and **Description**.
58
64
1. Ensure **Policy enforcement** is set to **Enabled**.
59
65
1. Select **Next**, then select **Next** again to open the **Parameters** tab.
@@ -63,23 +69,27 @@ built-in policy definition.
63
69
1. Select **Next** to open the **Remediation** task.
64
70
1. Enable **Create a remediation task**.
65
71
1. Verify that **Create a Managed Identity** is checked, and that the identity will have **Contributor** permissions.
66
-
* For more information, see [Quickstart: Create a policy assignment to identify non-compliant resources](../../governance/policy/assign-policy-portal.md) and [Remediate non-compliant resources with Azure Policy](../../governance/policy/how-to/remediate-resources.md).
72
+
73
+
For more information, see [Quickstart: Create a policy assignment to identify non-compliant resources](../../governance/policy/assign-policy-portal.md) and [Remediate non-compliant resources with Azure Policy](../../governance/policy/how-to/remediate-resources.md).
74
+
67
75
1. Select **Review + create**, then select **Create**.
68
76
69
77
After creating the policy assignments, the configuration is applied to new Azure Arc-enabled Kubernetes or AKS clusters created within the scope of policy assignment.
70
78
71
79
For existing clusters, you may need to manually run a remediation task. This task typically takes 10 to 20 minutes for the policy assignment to take effect.
72
80
73
-
## Verify a policy assignment
81
+
## Verify the policy assignment
74
82
75
83
1. In the Azure portal, navigate to one of your Azure Arc-enabled Kubernetes or AKS clusters.
76
84
1. In the **Settings** section of the sidebar, select **GitOps**.
77
-
* In the configurations list, you should see the configuration created by the policy assignment.
85
+
86
+
In the configurations list, you should see the configuration created by the policy assignment.
87
+
78
88
1. In the **Kubernetes resources** section of the sidebar, select **Namespaces** and **Workloads**.
79
-
* You should see the namespace and artifacts that were created by the Flux configuration.
80
-
* You should see the objects described by the manifests in the Git repo deployed on the cluster.
81
89
82
-
## Customizing a policy
90
+
You should see the namespace and artifacts that were created by the Flux configuration. You should also see the objects described by the manifests in the Git repo deployed on the cluster.
91
+
92
+
## Customize a policy
83
93
84
94
The built-in policies cover the main scenarios for using GitOps with Flux v2 in your Kubernetes clusters. However, due to limitations on the number of parameters allowed in Azure Policy assignments (max of 20), not all parameters are present in the built-in policies. Also, to fit within the 20-parameter limit, only a single Kustomization can be created with the built-in policies.
0 commit comments