|
| 1 | +--- |
| 2 | +title: Gated deployment for Infrastructure as Code |
| 3 | +description: Learn how to deploy gated deployment infrastructure as code for managed cluster API. |
| 4 | +#customer intent: As a Kubernetes administrator, I want to deploy gated deployment infrastructure as code so that I can automate the setup and ensure consistent configuration across environments. |
| 5 | +author: Elazark |
| 6 | +ms.author: elkrieger |
| 7 | +ms.date: 02/16/2026 |
| 8 | +ms.topic: how-to |
| 9 | +--- |
| 10 | + |
| 11 | +# Gated deployment for Infrastructure as Code |
| 12 | + |
| 13 | +Microsoft Defender for Cloud's gated deployment agent is a Kubernetes admission controller that enforces container image security policies at deployment time. Gated deployment acts as a gatekeeper for container images for known security problems at deployment time and decides whether they're allowed to run. |
| 14 | + |
| 15 | +The gated deployment agent requires read access to all of your Azure Container Registries (ACRs) associated with the cluster. These registries store the container images alongside the vulnerability assessment artifacts generated by Defender for Containers. To enable this access, configure a Managed Service Identity (MSI) with the required ACR read permissions and assign it to the agent. |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | +- An Azure subscription with Microsoft Defender for Cloud enabled. |
| 20 | +- You must [enable gated deployment in Defender for Containers](enablement-guide-runtime-gated.md) with the defender sensor and registry access extensions turned on. |
| 21 | +- You must enable on your Azure Kubernetes Service (AKS) cluster: |
| 22 | + - [An OpenID Connect (OIDC) issuer](/azure/aks/use-oidc-issuer#create-an-aks-cluster-with-the-oidc-issuer). |
| 23 | + - [An Azure Workload Identity](/azure/aks/workload-identity-deploy-cluster?tabs=new-cluster). |
| 24 | + |
| 25 | +> [!NOTE] |
| 26 | +> Security gating only needs to be installed once. The first time you enable the security gating toggle, it installs security gating. |
| 27 | +> After that, security gating is already installed. When the installation runs again, the system detects this and does nothing. |
| 28 | +> If you try to install it again through the API, it fails because security gating already exists. |
| 29 | +> |
| 30 | +> :::image type="content" source="media/gated-deployment-infrastructure-as-code/security-gating-on.png" alt-text="Screenshot that shows security gating is turned to on." lightbox="media/gated-deployment-infrastructure-as-code/security-gating-on.png"::: |
| 31 | +
|
| 32 | +## Deploy the gated agent |
| 33 | + |
| 34 | +1. [Create a Managed Service Identity (MSI) that the gated deployment agent uses](/entra/identity/managed-identities-azure-resources/manage-user-assigned-managed-identities-azure-portal). |
| 35 | + |
| 36 | +1. [Assign the AcrPull role (or equivalent read role)](/azure/container-registry/container-registry-rbac-built-in-roles-overview?tabs=registries-configured-with-rbac-registry-abac-repository-permissions) to the MSI on all ACRs the cluster uses. |
| 37 | + |
| 38 | +1. [Add a Federated Identity Credential (FIC) to the MSI](/graph/api/resources/federatedidentitycredentials-overview?view=graph-rest-1.0) that allows the gated deployment agent to authenticate by using AKS Workload Identity, with the following FIC parameters: |
| 39 | + |
| 40 | + - **Issuer**: The AKS OIDC issuer URL |
| 41 | + - **Subject**: The service account used by the gated deployment agent `system:serviceaccount:kube-system:defender-admission-controller-serviceaccount`. |
| 42 | + - **Audience**: api://AzureADTokenExchange |
| 43 | + |
| 44 | +1. Under the [securityGating section of the managed cluster API configuration](https://learn.microsoft.com/azure/templates/microsoft.containerservice/managedclusters?pivots=deployment-language-arm-template#resource-format-1), set the [MSI’s objectId in the identities parameter](https://learn.microsoft.com/azure/templates/microsoft.containerservice/managedclusters?pivots=deployment-language-arm-template#managedclustersecurityprofiledefendersecuritygating-1) under the security gating section of the managed cluster API configuration. |
| 45 | + |
| 46 | + :::image type="content" source="media/gated-deployment-infrastructure-as-code/identities.png" alt-text="Screenshot that shows the section of the securityGating section of the managed cluster API configuration, where the code is located." lightbox="media/gated-deployment-infrastructure-as-code/identities.png"::: |
| 47 | + |
| 48 | + This ensures the gated deployment agent can use the MSI at runtime. |
| 49 | + |
| 50 | +## Next step |
| 51 | + |
| 52 | +> [!div class="nextstep"] |
| 53 | +> [Troubleshoot gated deployment in Kubernetes](troubleshooting-runtime-gated.md) |
0 commit comments