Skip to content

Commit 50d76fd

Browse files
authored
Merge pull request #199048 from bmansheim/deploy-defender-profile-cli
Add CLI instructions for adding defender enabled containers
2 parents b8d1ed5 + e8b76fb commit 50d76fd

File tree

5 files changed

+105
-38
lines changed

5 files changed

+105
-38
lines changed

articles/defender-for-cloud/defender-for-containers-enable.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Learn about this plan in [Overview of Microsoft Defender for Containers](defende
2525
::: zone pivot="defender-for-container-arc,defender-for-container-eks,defender-for-container-gke"
2626
> [!NOTE]
2727
> Defender for Containers' support for Arc-enabled Kubernetes clusters, AWS EKS, and GCP GKE. This is a preview feature.
28-
>
28+
>
2929
> [!INCLUDE [Legalese](../../includes/defender-for-cloud-preview-legal-text.md)]
3030
::: zone-end
3131

@@ -70,7 +70,7 @@ A full list of supported alerts is available in the [reference table of all Defe
7070
1. In the Azure portal, open Microsoft Defender for Cloud's security alerts page and look for the alert on the relevant resource:
7171

7272
:::image type="content" source="media/defender-for-kubernetes-azure-arc/sample-kubernetes-security-alert.png" alt-text="Sample alert from Microsoft Defender for Kubernetes." lightbox="media/defender-for-kubernetes-azure-arc/sample-kubernetes-security-alert.png":::
73-
73+
7474
::: zone pivot="defender-for-container-arc,defender-for-container-eks,defender-for-container-gke"
7575
[!INCLUDE [Remove the extension](./includes/defender-for-containers-remove-extension.md)]
7676
::: zone-end
@@ -89,4 +89,4 @@ A full list of supported alerts is available in the [reference table of all Defe
8989

9090
## Next steps
9191

92-
[Use Defender for Containers to scan your ACR images for vulnerabilities](defender-for-container-registries-usage.md).
92+
[Use Defender for Containers to scan your ACR images for vulnerabilities](defender-for-container-registries-usage.md).

articles/defender-for-cloud/includes/defender-for-containers-enable-plan-aks.md

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
author: ElazarK
3-
ms.author: elkrieger
2+
author: bmansheim
3+
ms.author: benmansheim
44
ms.service: defender-for-cloud
55
ms.topic: include
66
ms.date: 05/12/2022
@@ -19,7 +19,7 @@ ms.date: 05/12/2022
1919
>
2020
> :::image type="content" source="../media/release-notes/defender-plans-deprecated-indicator.png" alt-text="Defender for container registries and Defender for Kubernetes plans showing 'Deprecated' and upgrade information.":::
2121
22-
1. By default, when enabling the plan through the Azure portal, [Microsoft Defender for Containers](../defender-for-containers-introduction.md) is configured to auto provision (automatically install) required components to provide the protections offered by plan, including the assignment of a default workspace.
22+
1. By default, when enabling the plan through the Azure portal, [Microsoft Defender for Containers](../defender-for-containers-introduction.md) is configured to auto provision (automatically install) required components to provide the protections offered by plan, including the assignment of a default workspace.
2323

2424
Optionally, you can modify this configuration from the [Defender plans page](https://portal.azure.com/#blade/Microsoft_Azure_Security/SecurityMenuBlade/pricingTier) or from the [Auto provisioning page](https://portal.azure.com/#blade/Microsoft_Azure_Security/SecurityMenuBlade/dataCollection) on the **Microsoft Defender for Containers components (preview)** row:
2525

@@ -39,7 +39,7 @@ ms.date: 05/12/2022
3939
> [!Note]
4040
>Microsoft Defender for Containers is configured to defend all of your clouds automatically. When you install all of the required prerequisites and enable all of the auto provisioning capabilities.
4141
>
42-
> If you choose to disable all of the auto provision configuration options, no agents, or components will be deployed to your clusters. Protection will be limited to the Agentless features only. Learn which features are Agentless in the [availability section](../supported-machines-endpoint-solutions-clouds-containers.md) for Defender for Containers.
42+
> If you choose to disable all of the auto provision configuration options, no agents, or components will be deployed to your clusters. Protection will be limited to the Agentless features only. Learn which features are Agentless in the [availability section](../supported-machines-endpoint-solutions-clouds-containers.md) for Defender for Containers.
4343
4444
## Deploy the Defender profile
4545

@@ -53,7 +53,7 @@ The Defender security profile is a preview feature. [!INCLUDE [Legalese](../../.
5353

5454
### Use the fix button from the Defender for Cloud recommendation
5555

56-
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.
56+
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.
5757

5858
A dedicated Defender for Cloud recommendation provides:
5959

@@ -73,7 +73,6 @@ A dedicated Defender for Cloud recommendation provides:
7373

7474
1. Select **Fix *[x]* resources**.
7575

76-
7776
### [**REST API**](#tab/aks-deploy-rest)
7877

7978
### Use the REST API to deploy the Defender profile
@@ -85,19 +84,18 @@ PUT https://management.azure.com/subscriptions/{{Subscription Id}}/resourcegroup
8584
```
8685

8786
Request URI: `https://management.azure.com/subscriptions/{{SubscriptionId}}/resourcegroups/{{ResourceGroup}}/providers/Microsoft.ContainerService/managedClusters/{{ClusterName}}?api-version={{ApiVersion}}`
88-
87+
8988
Request query parameters:
90-
89+
9190
| Name | Description | Mandatory |
9291
|----------------|------------------------------------|-----------|
9392
| SubscriptionId | Cluster's subscription ID | Yes |
9493
| ResourceGroup | Cluster's resource group | Yes |
9594
| ClusterName | Cluster's name | Yes |
9695
| ApiVersion | API version, must be >= 2021-07-01 | Yes |
9796

98-
9997
Request Body:
100-
98+
10199
```rest
102100
{
103101
"location": "{{Location}}",
@@ -111,7 +109,7 @@ Request Body:
111109
}
112110
}
113111
```
114-
112+
115113
Request body parameters:
116114

117115
| Name | Description | Mandatory |
@@ -120,7 +118,53 @@ Request body parameters:
120118
| properties.securityProfile.azureDefender.enabled | Determines whether to enable or disable Microsoft Defender for Containers on the cluster | Yes |
121119
| properties.securityProfile.azureDefender.logAnalyticsWorkspaceResourceId | Log Analytics workspace Azure resource ID | Yes |
122120

121+
### [**Azure CLI**](#tab/k8s-deploy-cli)
122+
123+
### Use Azure CLI to deploy the Defender extension
124+
125+
1. Log in to Azure:
126+
127+
```azurecli
128+
az login
129+
az account set --subscription <your-subscription-id>
130+
```
131+
132+
> [!IMPORTANT]
133+
> Ensure that you use the same subscription ID for ``<your-subscription-id>`` as the one associated with your AKS cluster.
134+
135+
1. Enable the feature flag in the CLI:
136+
137+
```azurecli
138+
az feature register --namespace Microsoft.ContainerService --name AKS-AzureDefender
139+
```
123140
141+
1. Enable the Defender profile on your containers:
142+
143+
- Run the following command to create a new cluster with the Defender profile enabled:
144+
145+
```azurecli
146+
az aks create --enable-defender --resource-group <your-resource-group> --name <your-cluster-name>
147+
```
148+
149+
- Run the following command to enable the Defender profile on an existing cluster:
150+
151+
```azurecli
152+
az aks update --enable-defender --resource-group <your-resource-group> --name <your-cluster-name>
153+
```
154+
155+
A description of all the supported configuration settings on the Defender extension type is given below:
156+
157+
| Property | Description |
158+
|----------|-------------|
159+
| logAnalyticsWorkspaceResourceID | **Optional**. Full resource ID of your own Log Analytics workspace.<br>When not provided, the default workspace of the region will be used.<br><br>To get the full resource ID, run the following command to display the list of workspaces in your subscriptions in the default JSON format:<br>```az resource list --resource-type Microsoft.OperationalInsights/workspaces -o json```<br><br>The Log Analytics workspace resource ID has the following syntax:<br>/subscriptions/{your-subscription-id}/resourceGroups/{your-resource-group}/providers/Microsoft.OperationalInsights/workspaces/{your-workspace-name}. <br>Learn more in [Log Analytics workspaces](../../azure-monitor/logs/log-analytics-workspace-overview.md) |
160+
161+
You can include these settings in a JSON file and specify the JSON file in the `az aks create` and `az aks update` commands with this parameter: `--defender-config<path-to-JSON-file>`. The format of the JSON file must be:
162+
163+
```json
164+
{"logAnalyticsWorkspaceResourceID": "<workspace-id>"}
165+
```
166+
167+
Learn more about AKS CLI commands in [az aks](/cli/azure/aks).
124168
125169
### [**Resource Manager**](#tab/aks-deploy-arm)
126170
@@ -149,4 +193,4 @@ To install the 'SecurityProfile' on an existing cluster with Resource Manager:
149193
},
150194
}
151195
}
152-
```
196+
```

articles/defender-for-cloud/includes/defender-for-containers-enable-plan-arc.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.date: 05/12/2022
1212

1313
1. From Defender for Cloud's menu, open the [Environment settings page](https://portal.azure.com/#blade/Microsoft_Azure_Security/SecurityMenuBlade/EnvironmentSettings) and select the relevant subscription.
1414

15-
1. In the [Defender plans page](https://portal.azure.com/#blade/Microsoft_Azure_Security/SecurityMenuBlade/pricingTier), enable **Defender for Containers**
15+
1. In the [Defender plans page](https://portal.azure.com/#blade/Microsoft_Azure_Security/SecurityMenuBlade/pricingTier), enable **Defender for Containers**.
1616

1717
> [!TIP]
1818
> 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**.
@@ -28,7 +28,7 @@ ms.date: 05/12/2022
2828
> [!NOTE]
2929
> 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.
3030
31-
You can [assign a custom workspace](https://docs.microsoft.com/azure/defender-for-cloud/defender-for-containers-enable?tabs=aks-deploy-portal%2Ck8s-deploy-asc%2Ck8s-verify-asc%2Ck8s-remove-arc%2Caks-removeprofile-api&pivots=defender-for-container-arc#assign-a-custom-workspace) through Azure Policy.
31+
You can [assign a custom workspace](../defender-for-containers-enable.md?tabs=aks-deploy-portal%2Ck8s-deploy-asc%2Ck8s-verify-asc%2Ck8s-remove-arc%2Caks-removeprofile-api&pivots=defender-for-container-arc#assign-a-custom-workspace) through Azure Policy.
3232

3333
1. If you disable the auto provisioning of any component, you can easily deploy the component to one or more clusters using the appropriate recommendation:
3434

@@ -39,6 +39,7 @@ ms.date: 05/12/2022
3939
## Prerequisites
4040

4141
Before deploying the extension, ensure you:
42+
4243
- [Connect the Kubernetes cluster to Azure Arc](../../azure-arc/kubernetes/quickstart-connect-cluster.md)
4344
- Complete the [pre-requisites listed under the generic cluster extensions documentation](../../azure-arc/kubernetes/extensions.md#prerequisites).
4445

@@ -72,7 +73,6 @@ A dedicated Defender for Cloud recommendation provides:
7273

7374
:::image type="content" source="../media/defender-for-kubernetes-azure-arc/security-center-deploy-extension.gif" alt-text="Deploy Defender extension for Azure Arc with Defender for Cloud's 'fix' option.":::
7475

75-
7676
### [**Azure CLI**](#tab/k8s-deploy-cli)
7777

7878
### Use Azure CLI to deploy the Defender extension
@@ -119,12 +119,13 @@ You can use the **azure-defender-extension-arm-template.json** Resource Manager
119119
120120
### [**REST API**](#tab/k8s-deploy-api)
121121
122-
### Use REST API to deploy the Defender extension
122+
### Use REST API to deploy the Defender extension
123123
124124
To use the REST API to deploy the Defender extension, you'll need a Log Analytics workspace on your subscription. Learn more in [Log Analytics workspaces](../../azure-monitor/logs/log-analytics-workspace-overview.md).
125125
126126
> [!TIP]
127127
> The simplest way to use the API to deploy the Defender extension is with the supplied **Postman Collection JSON** example from Defender for Cloud's [installation examples](https://aka.ms/kubernetes-extension-installation-examples).
128+
128129
- To modify the Postman Collection JSON, or to manually deploy the extension with the REST API, run the following PUT command:
129130
130131
```rest
@@ -139,12 +140,11 @@ To use the REST API to deploy the Defender extension, you'll need a Log Analytic
139140
|Resource Group | Path | True | String | Name of the resource group containing your Azure Arc-enabled Kubernetes resource |
140141
| Cluster Name | Path | True | String | Name of your Azure Arc-enabled Kubernetes resource |
141142
142-
143-
144143
For **Authentication**, your header must have a Bearer token (as with other Azure APIs). To get a bearer token, run the following command:
145144
146145
`az account get-access-token --subscription <your-subscription-id>`
147146
Use the following structure for the body of your message:
147+
148148
```json
149149
{
150150
"properties": {
@@ -162,10 +162,10 @@ To use the REST API to deploy the Defender extension, you'll need a Log Analytic
162162
163163
Description of the properties is given below:
164164
165-
| Property | Description |
165+
| Property | Description |
166166
| -------- | ----------- |
167167
| logAnalytics.workspaceId | Workspace ID of the Log Analytics resource |
168-
| logAnalytics.key | Key of the Log Analytics resource |
168+
| logAnalytics.key | Key of the Log Analytics resource |
169169
| auditLogPath | **Optional**. The full path to the audit log files. The default value is ``/var/log/kube-apiserver/audit.log`` |
170170
171171
---
@@ -186,7 +186,6 @@ To verify that your cluster has the Defender extension installed on it, follow t
186186
187187
1. Check that the cluster on which you deployed the extension is listed as **Healthy**.
188188
189-
190189
### [**Azure portal - Azure Arc**](#tab/k8s-verify-arc)
191190
192191
### Use the Azure Arc pages to verify the status of your extension
@@ -201,7 +200,6 @@ To verify that your cluster has the Defender extension installed on it, follow t
201200
202201
:::image type="content" source="../media/defender-for-kubernetes-azure-arc/extension-details-page.png" alt-text="Full details of an Azure Arc extension on a Kubernetes cluster.":::
203202
204-
205203
### [**Azure CLI**](#tab/k8s-verify-cli)
206204
207205
### Use Azure CLI to verify that the extension is deployed
@@ -216,9 +214,9 @@ To verify that your cluster has the Defender extension installed on it, follow t
216214
217215
> [!NOTE]
218216
> It might show "installState": "Pending" for the first few minutes.
219-
217+
220218
1. If the state shows **Installed**, run the following command on your machine with the `kubeconfig` file pointed to your cluster to check that a pod called "azuredefender-XXXXX" is in 'Running' state:
221-
219+
222220
```console
223221
kubectl get pods -n azuredefender
224222
```
@@ -247,5 +245,3 @@ To confirm a successful deployment, or to validate the status of your extension
247245
```
248246
249247
---
250-
251-

articles/defender-for-cloud/includes/defender-for-containers-remove-profile.md

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,38 @@ ms.author: elkrieger
99

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

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

1515
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](../enable-data-collection.md).
1616

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

19+
### [**Azure CLI**](#tab/k8s-remove-cli)
20+
21+
### Use Azure CLI to remove the Defender profile
22+
23+
1. Remove the Microsoft Defender for with the following commands:
24+
25+
```azurecli
26+
az login
27+
az account set --subscription <subscription-id>
28+
az aks update --disable-defender
29+
```
30+
31+
Removing the profile may take a few minutes.
32+
33+
1. To verify that the profile was successfully removed, run the following command:
34+
35+
```console
36+
kubectl get pods -n azuredefender
37+
```
38+
39+
When the profile is removed, you should see that no pods are returned in the `get pods` command. It might take a few minutes for the pods to be deleted.
40+
1941
### [**REST API**](#tab/aks-removeprofile-api)
2042
21-
### Use REST API to remove the Defender profile from AKS
43+
### Use REST API to remove the Defender profile from AKS
2244
2345
To remove the profile using the REST API, run the following PUT command:
2446
@@ -33,9 +55,8 @@ https://management.azure.com/subscriptions/{{SubscriptionId}}/resourcegroups/{{R
3355
| ClusterName | Cluster's name | Yes |
3456
| ApiVersion | API version, must be >= 2021-07-01 | Yes |
3557

36-
3758
Request body:
38-
59+
3960
```rest
4061
{
4162
"location": "{{Location}}",
@@ -48,16 +69,14 @@ Request body:
4869
}
4970
}
5071
```
51-
72+
5273
Request body parameters:
5374

5475
| Name | Description | Mandatory |
5576
|--------------------------------------------------------------------------|------------------------------------------------------------------------------------------|-----------|
5677
| location | Cluster's location | Yes |
5778
| properties.securityProfile.azureDefender.enabled | Determines whether to enable or disable Microsoft Defender for Containers on the cluster | Yes |
5879

59-
60-
6180
### [**Resource Manager**](#tab/aks-removeprofile-resource-manager)
6281

6382
### Use Azure Resource Manager to remove the Defender profile from AKS
@@ -69,7 +88,7 @@ To use Azure Resource Manager to remove the Defender profile, you'll need a Log
6988
7089
The relevant template and parameters to remove the Defender profile from AKS are:
7190

72-
```
91+
```json
7392
{
7493
"type": "Microsoft.ContainerService/managedClusters",
7594
"apiVersion": "2021-07-01",

0 commit comments

Comments
 (0)