Configure Microsoft Defender for Containers components

Microsoft Defender for Containers is the cloud-native solution for securing your containers.

Defender for Containers protects your clusters whether they're running in:

  • Azure Kubernetes Service (AKS) - Microsoft's managed service for developing, deploying, and managing containerized applications.
  • Other Kubernetes distributions (using Azure Arc-enabled Kubernetes) - Cloud Native Computing Foundation (CNCF) certified Kubernetes clusters hosted on-premises or on IaaS.

Learn about this plan in Overview of Microsoft Defender for Containers.

You can first learn how to connect and protect your containers in these articles:

Network requirements

Validate the following endpoints are configured for outbound access so that the Defender sensor can connect to Microsoft Defender for Cloud to send security data and events:

See the required FQDN/application rules for Microsoft Defender for Containers.

By default, AKS clusters have unrestricted outbound (egress) internet access.

Enable the plan

To enable the plan:

  1. From Defender for Cloud's menu, open the Settings page and select the relevant subscription.

  2. In the Defender plans page, select Defender for Containers and select Settings.

    screenshot of Defender plans page.

    Tip

    If the subscription already has Defender for Kubernetes and/or Defender for container registries enabled, an update notice is shown. Otherwise, the only option will be Defender for Containers.

    Defender for container registries and Defender for Kubernetes plans showing 'Deprecated' and upgrade information.

  3. Turn the relevant component on to enable it.

    screenshot of turning on components.

    Note

    • Defenders for Containers customers who joined before August 2023 and don't have Agentless discovery for Kubernetes enabled as part of Defender CSPM when they enabled the plan, must manually enable the Agentless discovery for Kubernetes extension within the Defender for Containers plan.
    • When you turn off Defender for Containers, the components are set to off and are not deployed to any more containers but they are not removed from containers that they are already installed on.

Enablement method per capability

By default, when enabling the plan through the Azure portal, Microsoft Defender for Containers is configured to automatically enable all capabilities and install all required components to provide the protections offered by the plan, including the assignment of a default workspace.

If you don't want to enable all capabilities of the plans, you can manually select which specific capabilities to enable by selecting Edit configuration for the Containers plan. Then, in the Settings & monitoring page, select the capabilities you want to enable. In addition, you can modify this configuration from the Defender plans page after initial configuration of the plan.

For detailed information on the enablement method for each one the capabilities, see the support matrix.

Roles and permissions

Learn more about the roles used to provision Defender for Containers extensions.

Assigning custom workspace for Defender sensor

You can assign a custom workspace through Azure Policy.

Manual deployment of Defender sensor or Azure policy agent without auto-provisioning using recommendations

Capabilities that require sensor installation can also be deployed on one or more Kubernetes clusters, using the appropriate recommendation:

Sensor Recommendation
Defender Sensor for Kubernetes Azure Kubernetes Service clusters should have Defender profile enabled
Defender Sensor for Arc-enabled Kubernetes Azure Arc-enabled Kubernetes clusters should have the Defender extension installed
Azure policy agent for Kubernetes Azure Kubernetes Service clusters should have the Azure Policy Add-on for Kubernetes installed
Azure policy agent for Arc-enabled Kubernetes Azure Arc-enabled Kubernetes clusters should have the Azure Policy extension installed

Perform the following steps to perform deployment of the Defender sensor on specific clusters:

  1. From Microsoft Defender for Cloud's recommendations page, open the Enable enhanced security security control or search directly for one of the above recommendations (or use the above links to open the recommendation directly)

  2. View all clusters without a sensor via the unhealthy tab.

  3. Select the clusters to deploy the desired sensor on and select Fix.

  4. Select Fix X resources.

Deploying Defender sensor - all options

You can enable the Defender for Containers plan and deploy all of the relevant components from the Azure portal, the REST API, or with a Resource Manager template. For detailed steps, select the relevant tab.

Once the Defender sensor has been deployed, a default workspace is automatically assigned. You can assign a custom workspace in place of the default workspace through Azure Policy.

Note

The Defender sensor is deployed to each node to provide the runtime protections and collect signals from those nodes using eBPF technology.

Use the fix button from the Defender for Cloud recommendation

A streamlined, frictionless, process lets you use the Azure portal pages to enable the Defender for Cloud plan and setup auto provisioning of all the necessary components for defending your Kubernetes clusters at scale.

A dedicated Defender for Cloud recommendation provides:

  • Visibility about which of your clusters has the Defender sensor deployed
  • Fix button to deploy it to those clusters without the sensor
  1. From Microsoft Defender for Cloud's recommendations page, open the Enable enhanced security security control.

  2. Use the filter to find the recommendation named Azure Kubernetes Service clusters should have Defender profile enabled.

    Tip

    Notice the Fix icon in the actions column

  3. Select the clusters to see the details of the healthy and unhealthy resources - clusters with and without the sensor.

  4. From the unhealthy resources list, select a cluster and select Remediate to open the pane with the remediation confirmation.

  5. Select Fix X resources.

Enable the plan

To enable the plan:

  1. From Defender for Cloud's menu, open the Settings page and select the relevant subscription.

  2. In the Defender plans page, select Defender for Containers and select Settings. screenshot of Defender plans page.

    Tip

    If the subscription already has Defender for Kubernetes or Defender for container registries enabled, an update notice is shown. Otherwise, the only option will be Defender for Containers.

    Defender for container registries and Defender for Kubernetes plans showing 'Deprecated' and upgrade information.

  3. Turn the relevant component on to enable it.

    screenshot of turning on components.

    Note

    When you turn off Defender for Containers, the components are set to off and are not deployed to any more containers but they are not removed from containers that they are already installed on.

By default, when enabling the plan through the Azure portal, Microsoft Defender for Containers is configured to automatically install required components to provide the protections offered by plan, including the assignment of a default workspace.

If you want to disable automatic installation of components during the onboarding process, select Edit configuration for the Containers plan. The Advanced options will appear, and you can disable automatic installation for each component.

In addition, you can modify this configuration from the Defender plans page.

Note

If you choose to disable the plan at any time after enabling it through the portal as shown above, you'll need to manually remove Defender for Containers components deployed on your clusters.

You can assign a custom workspace through Azure Policy.

If you disable the automatic installation of any component, you can easily deploy the component to one or more clusters using the appropriate recommendation:

Learn more about the roles used to provision Defender for Containers extensions.

Prerequisites

Before deploying the sensor, ensure you:

Deploy the Defender sensor

You can deploy the Defender sensor using a range of methods. For detailed steps, select the relevant tab.

Use the fix button from the Defender for Cloud recommendation

A dedicated Defender for Cloud recommendation provides:

  • Visibility about which of your clusters has the Defender sensor deployed
  • Fix button to deploy it to those clusters without the sensor
  1. From Microsoft Defender for Cloud's recommendations page, open the Enable enhanced security security control.

  2. Use the filter to find the recommendation named Azure Arc-enabled Kubernetes clusters should have Defender for Cloud's extension installed.

    Microsoft Defender for Cloud's recommendation for deploying the Defender sensor for Azure Arc-enabled Kubernetes clusters.

    Tip

    Notice the Fix icon in the actions column

  3. Select the sensor to see the details of the healthy and unhealthy resources - clusters with and without the sensor.

  4. From the unhealthy resources list, select a cluster and select Remediate to open the pane with the remediation options.

  5. Select the relevant Log Analytics workspace and select Remediate x resource.

    Deploy Defender sensor for Azure Arc with Defender for Cloud's 'fix' option.

Verify the deployment

To verify that your cluster has the Defender sensor installed on it, follow the steps in one of the tabs below:

Use Defender for Cloud recommendation to verify the status of your sensor

  1. From Microsoft Defender for Cloud's recommendations page, open the Enable Microsoft Defender for Cloud security control.

  2. Select the recommendation named Azure Arc-enabled Kubernetes clusters should have Microsoft Defender for Cloud's extension installed.

    Microsoft Defender for Cloud's recommendation for deploying the Defender sensor for Azure Arc-enabled Kubernetes clusters.

  3. Check that the cluster on which you deployed the sensor is listed as Healthy.

Simulate security alerts from Microsoft Defender for Containers

A full list of supported alerts is available in the reference table of all Defender for Cloud security alerts.

  1. To simulate a security alert, run the following command from the cluster:

    kubectl get pods --namespace=asc-alerttest-662jfi039n
    

    The expected response is No resource found.

    Within 30 minutes, Defender for Cloud detects this activity and trigger a security alert.

    Note

    To simulate agentless alerts for Defender for Containers, Azure Arc isn't a prerequisite.

  2. In the Azure portal, open Microsoft Defender for Cloud's security alerts page and look for the alert on the relevant resource:

    Sample alert from Microsoft Defender for Kubernetes.

Remove the Defender sensor

To remove this - or any - Defender for Cloud extension, it's not enough to turn off auto provisioning:

  • Enabling auto provisioning, potentially impacts existing and future machines.
  • Disabling auto provisioning for an extension, only affects the future machines - nothing is uninstalled by disabling auto provisioning.

Note

To turn off the Defender for Containers plan entirely, go to Environment settings and disable the Microsoft Defender for Containers plan.

Nevertheless, to ensure the Defender for Containers components aren't automatically provisioned to your resources from now on, disable auto provisioning of the extensions as explained in Configure auto provisioning for agents and extensions from Microsoft Defender for Cloud.

You can remove the extension using Azure portal, Azure CLI, or REST API as explained in the tabs below.

Use Azure portal to remove the extension

  1. From the Azure portal, open Azure Arc.

  2. From the infrastructure list, select Kubernetes clusters and then select the specific cluster.

  3. Open the extensions page. The extensions on the cluster are listed.

  4. Select the cluster and select Uninstall.

    Removing an extension from your Arc-enabled Kubernetes cluster.

Remove the Defender sensor

To remove this - or any - Defender for Cloud extension, it's not enough to turn off auto provisioning:

  • Enabling auto provisioning, potentially impacts existing and future machines.
  • Disabling auto provisioning for an extension, only affects the future machines - nothing is uninstalled by disabling auto provisioning.

Note

To turn off the Defender for Containers plan entirely, go to Environment settings and disable the Microsoft Defender for Containers plan.

Nevertheless, to ensure the Defender for Containers components aren't automatically provisioned to your resources from now on, disable auto provisioning of the extensions as explained in Configure auto provisioning for agents and extensions from Microsoft Defender for Cloud.

You can remove the extension using the REST API or a Resource Manager template as explained in the tabs below.

Use REST API to remove the Defender sensor from AKS

To remove the extension using the REST API, run the following PUT command:

https://management.chinacloudapi.cn/subscriptions/{{SubscriptionId}}/resourcegroups/{{ResourceGroup}}/providers/Microsoft.ContainerService/managedClusters/{{ClusterName}}?api-version={{ApiVersion}}
Name Description Mandatory
SubscriptionId Cluster's subscription ID Yes
ResourceGroup Cluster's resource group Yes
ClusterName Cluster's name Yes
ApiVersion API version, must be >= 2022-06-01 Yes

Request body:

{
  "location": "{{Location}}",
  "properties": {
    "securityProfile": {
            "defender": {
                "securityMonitoring": {
                    "enabled": false
                }
            }
        }
    }
}

Request body parameters:

Name Description Mandatory
location Cluster's location Yes
properties.securityProfile.defender.securityMonitoring.enabled Determines whether to enable or disable Microsoft Defender for Containers on the cluster Yes

Next steps

Now that you enabled Defender for Containers, you can: