Skip to content

Commit 6978c25

Browse files
authored
Merge pull request #232235 from rsgel/main
Add Azure portal instructions for enabling VNet injection in Chaos Studio
2 parents dd9f491 + 21a75f1 commit 6978c25

File tree

5 files changed

+82
-48
lines changed

5 files changed

+82
-48
lines changed
Lines changed: 82 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,151 @@
11
---
22
title: Integration of VNet Injection with Chaos Studio
3-
description: Chaos Studio supports VNet Injections
3+
description: Learn how to use VNet injection with Chaos Studio
44
services: chaos-studio
55
author: prashabora
66
ms.topic: conceptual
77
ms.date: 10/26/2022
88
ms.author: prashabora
99
ms.service: chaos-studio
1010
---
11-
# VNet Injection in Chaos Studio
11+
# VNet injection in Chaos Studio
1212

13-
VNet is the fundamental building block for your private network in Azure. VNet enables many Azure resources to securely communicate with each other, the internet, and on-premises networks. VNet is like a traditional network you would operate in your own data center. However, VNet also has the benefits of Azure infrastructure, scale, availability, and isolation.
13+
Azure [Virtual Network](../virtual-network/virtual-networks-overview.md) (VNet) is the fundamental building block for your private network in Azure. VNet enables many types of Azure resources to securely communicate with each other, the internet, and on-premises networks. VNet is similar to a traditional network that you'd operate in your own data center, but brings with it other benefits of Azure's infrastructure such as scale, availability, and isolation.
1414

15-
## How VNet Injection works in Chaos Studio
15+
VNet injection allows a Chaos resource provider to inject containerized workloads into your VNet so that resources without public endpoints can be accessed via a private IP address on the VNet. Once you've configured VNet injection for a resource in a VNet and enabled the resource as a target, you can use it in multiple experiments. An experiment can target a mix of private and non-private resources, as long as the private resources have been configured according to the instructions on this page.
1616

17-
VNet injection allows a Chaos resource provider to inject containerized workloads into your VNet so that resources without public endpoints can be accessed via a private IP address on the VNet. To configure VNet injection:
17+
## Resource type support
18+
Currently, you can only enable certain resource types for Chaos Studio VNet injection.
19+
* **Azure Kubernetes Service** targets can be enabled with VNet injection through the **Azure portal** and **Azure CLI**. All AKS Chaos Mesh faults can be used.
20+
* **Key Vault** targets can be enabled with VNet injection through the **Azure CLI**. The faults that can be used with VNet Injection are Disable Certificate, Increment Certificate Version, and Update Certificate Policy.
1821

19-
1. Register the `Microsoft.ContainerInstance` and `Microsoft.Relay` resource providers with your subscription (if applicable).
22+
## Enabling VNet injection
23+
To use Chaos Studio with VNet injection, you need to meet the following requirements.
24+
1. The `Microsoft.ContainerInstance` and `Microsoft.Relay` resource providers must be registered with your subscription.
25+
1. The VNet where Chaos Studio resources will be injected needs to have two subnets, named `ChaosStudioContainerSubnet` and `ChaosStudioRelaySubnet`. Other subnet names can't be used.
26+
1. Both subnets need at least `/28` in address space. For example, an address prefix of `10.0.0.0/28` or `10.0.0.0/24`.
27+
1. `ChaosStudioContainerSubnet` must be delegated to `Microsoft.ContainerInstance/containerGroups`.
28+
1. When enabling the desired resource as a target so you can use it in Chaos Studio experiments, the following properties must be set:
29+
1. Set `properties.subnets.containerSubnetId` to the ID for `ChaosStudioContainerSubnet`.
30+
1. Set `properties.subnets.relaySubnetId` to the ID for `ChaosStudioRelaySubnet`.
2031

21-
```bash
22-
az provider register --namespace 'Microsoft.ContainerInstance' --wait
23-
```
32+
## Example: Use Chaos Studio with a private AKS cluster
2433

25-
Verify the registration by running the following command:
34+
This example shows how to configure a private AKS cluster to use with Chaos Studio. It assumes you already have a private AKS cluster within your Azure subscription. To create one, see: [Create a private Azure Kubernetes Service cluster](../aks/private-clusters.md)
2635

27-
```bash
28-
az provider show --namespace 'Microsoft.ContainerInstance' | grep registrationState
29-
```
36+
### [Azure portal](#tab/azure-portal)
3037

31-
In the output, you should see something similar to:
38+
1. Within the Azure portal, navigate to **Subscriptions**, then **Resource providers** within your subscription.
39+
1. Register the `Microsoft.ContainerInstance` and `Microsoft.Relay` resource providers, if they aren't already registered, by selecting the provider and then the **Register** button. Additionally, re-register the `Microsoft.Chaos` resource provider.
40+
:::image type="content" source="images/vnet-register-resource-provider.png" alt-text="Screenshot of how to register a resource provider." lightbox="images/vnet-register-resource-provider.png":::
41+
1. Navigate to Azure Chaos Studio and select **Targets**. Find your desired AKS cluster and select **Enable targets**, then **Enable service-direct targets**.
42+
:::image type="content" source="images/vnet-enable-targets.png" alt-text="Screenshot of how to enable targets in Chaos Studio." lightbox="images/vnet-enable-targets.png":::
43+
1. Select the cluster's Virtual Network. If the VNet already includes subnets named `ChaosStudioContainerSubnet` and `ChaosStudioRelaySubnet`, select them. If they don't already exist, they'll be automatically created for you.
44+
:::image type="content" source="images/vnet-select-subnets.png" alt-text="Screenshot of how to select the VNet and Subnets." lightbox="images/vnet-select-subnets.png":::
45+
1. Select **Review + Enable** and **Enable**.
46+
:::image type="content" source="images/vnet-review.png" alt-text="Screenshot of how to review the target enablement." lightbox="images/vnet-review.png":::
3247

33-
```bash
34-
"registrationState": "Registered",
35-
```
48+
Now your private AKS cluster can be used with Chaos Studio! Use the following instructions to learn how to install Chaos Mesh and run the experiment: [Create a chaos experiment that uses a Chaos Mesh fault with the Azure portal](chaos-studio-tutorial-aks-portal.md).
49+
50+
### [Azure CLI](#tab/azure-cli)
3651

37-
1. Register the `Microsoft.Relay` resource provider with your subscription.
52+
1. Register the `Microsoft.ContainerInstance` and `Microsoft.Relay` resource providers with your subscription by running the following commands. If they're both already registered, you can skip this step. For more detail, see the [Register resource provider](../azure-resource-manager/management/resource-providers-and-types.md) instructions.
53+
54+
```azurecli
55+
az provider register --namespace 'Microsoft.ContainerInstance' --wait
56+
```
3857
39-
```bash
58+
```azurecli
4059
az provider register --namespace 'Microsoft.Relay' --wait
4160
```
4261
43-
Verify the registration by running the following command:
62+
Verify the registration by running the following commands:
63+
64+
```azurecli
65+
az provider show --namespace 'Microsoft.ContainerInstance' | grep registrationState
66+
```
4467
45-
```bash
68+
```azurecli
4669
az provider show --namespace 'Microsoft.Relay' | grep registrationState
4770
```
4871
4972
In the output, you should see something similar to:
5073
51-
```bash
74+
```azurecli
5275
"registrationState": "Registered",
5376
```
5477
5578
1. Re-register the `Microsoft.Chaos` resource provider with your subscription.
5679
57-
```bash
80+
```azurecli
5881
az provider register --namespace 'Microsoft.Chaos' --wait
5982
```
6083
6184
Verify the registration by running the following command:
6285
63-
```bash
86+
```azurecli
6487
az provider show --namespace 'Microsoft.Chaos' | grep registrationState
6588
```
6689
6790
In the output, you should see something similar to:
6891
69-
```bash
92+
```azurecli
7093
"registrationState": "Registered",
7194
```
7295
73-
1. Create two subnets in the VNet you want to inject into:
96+
1. Create two subnets in the VNet you want to inject Chaos Studio resources into (in this case, the private AKS cluster's VNet):
7497
7598
- `ChaosStudioContainerSubnet`
76-
- Delegate the subnet to `Microsoft.ContainerInstance/containerGroups` service.
77-
- This subnet must have at least /28 in address space
99+
- Delegate the subnet to the `Microsoft.ContainerInstance/containerGroups` service.
100+
- This subnet must have at least /28 in address space.
78101
- `ChaosStudioRelaySubnet`
79-
- This subnet must have at least /28 in address space
102+
- This subnet must have at least /28 in address space.
103+
104+
```azurecli
105+
az network vnet subnet create -g MyResourceGroup --vnet-name MyVnetName --name ChaosStudioContainerSubnet --address-prefixes "10.0.0.0/28" --delegations "Microsoft.ContainerInstance/containerGroups"
106+
```
107+
```azurecli
108+
az network vnet subnet create -g MyResourceGroup --vnet-name MyVnetName --name ChaosStudioRelaySubnet --address-prefixes "10.0.0.0/28"
109+
```
80110
81-
1. Set the `properties.subnets.containerSubnetId` and `properties.subnets.relaySubnetId` properties when you create or update the Target resource. The value should be the resource ID of the subnet created in step 3.
111+
1. When enabling targets for the AKS cluster, so you can use it in Chaos Experiments, set the `properties.subnets.containerSubnetId` and `properties.subnets.relaySubnetId` properties using the new subnets you created in step 3.
82112
83-
Replace `$SUBSCRIPTION_ID` with your Azure subscription ID, `$RESOURCE_GROUP` and `$AKS_CLUSTER` with the resource group name and your AKS cluster resource name. Also, replace `$AKS_INFRA_RESOURCE_GROUP` and `$AKS_VNET` with your AKS's infrastructure resource group name and VNet name.
113+
Replace `$SUBSCRIPTION_ID` with your Azure subscription ID, `$RESOURCE_GROUP` and `$AKS_CLUSTER` with the resource group name and your AKS cluster resource name. Also, replace `$AKS_INFRA_RESOURCE_GROUP` and `$AKS_VNET` with your AKS's infrastructure resource group name and VNet name. Replace `$URL` with the corresponding `https://management.azure.com/` URL used for onboarding the target.
84114
85-
```bash
115+
```azurecli
86116
CONTAINER_SUBNET_ID=/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$AKS_INFRA_RESOURCE_GROUP/providers/Microsoft.Network/virtualNetworks/$AKS_VNET/subnets/ChaosStudioContainerSubnet
87117
RELAY_SUBNET_ID=/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$AKS_INFRA_RESOURCE_GROUP/providers/Microsoft.Network/virtualNetworks/$AKS_VNET/subnets/ChaosStudioRelaySubnet
88118
BODY="{ \"properties\": { \"subnets\": { \"containerSubnetId\": \"$CONTAINER_SUBNET_ID\", \"relaySubnetId\": \"$RELAY_SUBNET_ID\" } } }"
89119
az rest --method put --url $URL --body "$BODY"
90120
```
121+
<!--
122+
After creating a Target resource with VNet injection enabled, the resource's properties will include:
123+
124+
```json
125+
{
126+
"properties": {
127+
"subnets": {
128+
"containerSubnetId": "/subscriptions/.../subnets/ChaosStudioContainerSubnet",
129+
"relaySubnetId": "/subscriptions/.../subnets/ChaosStudioRelaySubnet"
130+
}
131+
}
132+
}
133+
```
134+
-->
91135
92-
1. Start the experiment.
136+
Now your private AKS cluster can be used with Chaos Studio! Use the following instructions to learn how to install Chaos Mesh and run the experiment: [Create a chaos experiment that uses a Chaos Mesh fault with the Azure CLI](chaos-studio-tutorial-aks-cli.md).
93137
94-
## Limitations
95-
* VNet injection is currently only possible in subscriptions/regions where Azure Container Instances and Azure Relay are available. They're deployed to target regions.
96-
* When you create a Target resource that you'll enable with VNet injection, you need Microsoft.Network/virtualNetworks/subnets/write access to the virtual network. For example, if the AKS cluster is deployed to VNet_A, then you must have permissions to create subnets in VNet_A in order to enable VNet injection for the AKS cluster. You have to specify a subnet (in VNet_A) that the container will be deployed to.
138+
---
97139
98-
Request Body when created Target resource with VNet injection enabled:
140+
## Limitations
141+
* VNet injection is currently only possible in subscriptions/regions where Azure Container Instances and Azure Relay are available.
142+
* When you create a Target resource that you'll enable with VNet injection, you need `Microsoft.Network/virtualNetworks/subnets/write` access to the virtual network. For example, if the AKS cluster is deployed to VNet_A, then you must have permissions to create subnets in VNet_A in order to enable VNet injection for the AKS cluster.
99143
100-
```json
101-
{
102-
"properties": {
103-
"subnets": {
104-
"containerSubnetId": "/subscriptions/.../subnets/ChaosStudioContainerSubnet",
105-
"relaySubnetId": "/subscriptions/.../subnets/ChaosStudioRelaySubnet"
106-
}
107-
}
108-
}
109-
```
110144
<!--
111145
![Target resource with VNet Injection](images/chaos-studio-rp-vnet-injection.png)
112146
-->
113147
114148
## Next steps
115-
Now that you understand how VNet Injection can be achieved for Chaos Studio, you're ready to:
149+
Now that you understand how VNet injection can be achieved for Chaos Studio, you're ready to:
116150
- [Create and run your first experiment](chaos-studio-tutorial-service-direct-portal.md)
117151
- [Create and run your first Azure Kubernetes Service experiment](chaos-studio-tutorial-aks-portal.md)
126 KB
Loading
239 KB
Loading
102 KB
Loading
130 KB
Loading

0 commit comments

Comments
 (0)