|
1 | 1 | ---
|
2 | 2 | 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 |
4 | 4 | services: chaos-studio
|
5 | 5 | author: prashabora
|
6 | 6 | ms.topic: conceptual
|
7 | 7 | ms.date: 10/26/2022
|
8 | 8 | ms.author: prashabora
|
9 | 9 | ms.service: chaos-studio
|
10 | 10 | ---
|
11 |
| -# VNet Injection in Chaos Studio |
| 11 | +# VNet injection in Chaos Studio |
12 | 12 |
|
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. |
14 | 14 |
|
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. |
16 | 16 |
|
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. |
18 | 21 |
|
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`. |
20 | 31 |
|
21 |
| - ```bash |
22 |
| - az provider register --namespace 'Microsoft.ContainerInstance' --wait |
23 |
| - ``` |
| 32 | +## Example: Use Chaos Studio with a private AKS cluster |
24 | 33 |
|
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) |
26 | 35 |
|
27 |
| - ```bash |
28 |
| - az provider show --namespace 'Microsoft.ContainerInstance' | grep registrationState |
29 |
| - ``` |
| 36 | +### [Azure portal](#tab/azure-portal) |
30 | 37 |
|
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"::: |
32 | 47 |
|
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) |
36 | 51 |
|
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 | + ``` |
38 | 57 |
|
39 |
| - ```bash |
| 58 | + ```azurecli |
40 | 59 | az provider register --namespace 'Microsoft.Relay' --wait
|
41 | 60 | ```
|
42 | 61 |
|
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 | + ``` |
44 | 67 |
|
45 |
| - ```bash |
| 68 | + ```azurecli |
46 | 69 | az provider show --namespace 'Microsoft.Relay' | grep registrationState
|
47 | 70 | ```
|
48 | 71 |
|
49 | 72 | In the output, you should see something similar to:
|
50 | 73 |
|
51 |
| - ```bash |
| 74 | + ```azurecli |
52 | 75 | "registrationState": "Registered",
|
53 | 76 | ```
|
54 | 77 |
|
55 | 78 | 1. Re-register the `Microsoft.Chaos` resource provider with your subscription.
|
56 | 79 |
|
57 |
| - ```bash |
| 80 | + ```azurecli |
58 | 81 | az provider register --namespace 'Microsoft.Chaos' --wait
|
59 | 82 | ```
|
60 | 83 |
|
61 | 84 | Verify the registration by running the following command:
|
62 | 85 |
|
63 |
| - ```bash |
| 86 | + ```azurecli |
64 | 87 | az provider show --namespace 'Microsoft.Chaos' | grep registrationState
|
65 | 88 | ```
|
66 | 89 |
|
67 | 90 | In the output, you should see something similar to:
|
68 | 91 |
|
69 |
| - ```bash |
| 92 | + ```azurecli |
70 | 93 | "registrationState": "Registered",
|
71 | 94 | ```
|
72 | 95 |
|
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): |
74 | 97 |
|
75 | 98 | - `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. |
78 | 101 | - `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 | + ``` |
80 | 110 |
|
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. |
82 | 112 |
|
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. |
84 | 114 |
|
85 |
| - ```bash |
| 115 | + ```azurecli |
86 | 116 | CONTAINER_SUBNET_ID=/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$AKS_INFRA_RESOURCE_GROUP/providers/Microsoft.Network/virtualNetworks/$AKS_VNET/subnets/ChaosStudioContainerSubnet
|
87 | 117 | RELAY_SUBNET_ID=/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$AKS_INFRA_RESOURCE_GROUP/providers/Microsoft.Network/virtualNetworks/$AKS_VNET/subnets/ChaosStudioRelaySubnet
|
88 | 118 | BODY="{ \"properties\": { \"subnets\": { \"containerSubnetId\": \"$CONTAINER_SUBNET_ID\", \"relaySubnetId\": \"$RELAY_SUBNET_ID\" } } }"
|
89 | 119 | az rest --method put --url $URL --body "$BODY"
|
90 | 120 | ```
|
| 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 | + --> |
91 | 135 |
|
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). |
93 | 137 |
|
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 | +--- |
97 | 139 |
|
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. |
99 | 143 |
|
100 |
| -```json |
101 |
| -{ |
102 |
| - "properties": { |
103 |
| - "subnets": { |
104 |
| - "containerSubnetId": "/subscriptions/.../subnets/ChaosStudioContainerSubnet", |
105 |
| - "relaySubnetId": "/subscriptions/.../subnets/ChaosStudioRelaySubnet" |
106 |
| - } |
107 |
| - } |
108 |
| -} |
109 |
| -``` |
110 | 144 | <!--
|
111 | 145 | 
|
112 | 146 | -->
|
113 | 147 |
|
114 | 148 | ## 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: |
116 | 150 | - [Create and run your first experiment](chaos-studio-tutorial-service-direct-portal.md)
|
117 | 151 | - [Create and run your first Azure Kubernetes Service experiment](chaos-studio-tutorial-aks-portal.md)
|
0 commit comments