|
| 1 | +--- |
| 2 | +title: Azure CLI & Azure portal example experiments |
| 3 | +description: See real examples of creating various chaos experiments in the Azure portal and CLI. |
| 4 | +services: chaos-studio |
| 5 | +author: nikhilkaul-msft |
| 6 | +ms.topic: reference |
| 7 | +ms.date: 05/07/2024 |
| 8 | +ms.author: abbyweisberg |
| 9 | +ms.reviewer: nikhilkaul |
| 10 | +ms.service: chaos-studio |
| 11 | +ms.custom: none |
| 12 | +--- |
| 13 | + |
| 14 | +# Example Experiments |
| 15 | + |
| 16 | +This article provides examples for creating experiments from your command line (CLI) and Azure portal parameter examples for various experiments. You can copy and paste the following commands into the CLI or Azure portal, and edit them for your specific resources. |
| 17 | + |
| 18 | +Here's an example of where you would copy and paste the Azure portal parameter into: |
| 19 | + |
| 20 | +[](images/azure-portal-parameter-examples.png#lightbox) |
| 21 | + |
| 22 | +> [!NOTE] |
| 23 | +> Make sure your experiment has permission to operate on **ALL** resources within the experiment. These examples exclusively use **System-assigned managed identity**, but we also support User-assigned managed identity. For more information, see [Experiment permissions](chaos-studio-permissions-security.md). |
| 24 | +><br> |
| 25 | +><br> |
| 26 | +>View all available role assignments [here](chaos-studio-fault-providers.md) to determine which permissions are required for your target resources. |
| 27 | +
|
| 28 | +--- |
| 29 | +Azure Kubernetes Service (AKS) Network Delay |
| 30 | +--- |
| 31 | + |
| 32 | +### [Azure CLI](#tab/azure-CLI) |
| 33 | +```AzCLI |
| 34 | +PUT https://management.azure.com/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment?api-version=2024-01-01 |
| 35 | +
|
| 36 | +{ |
| 37 | +
|
| 38 | +"identity": { |
| 39 | + "type": "SystemAssigned", |
| 40 | + "principalId": "35g5795t-8sd4-5b99-a7c8-d5asdh9as7", |
| 41 | + "tenantId": "asd79ash-7daa-95hs-0as8-f3md812e3md" |
| 42 | + }, |
| 43 | + "tags": {}, |
| 44 | + "location": "westus", |
| 45 | + "properties": { |
| 46 | + "provisioningState": "Succeeded", |
| 47 | + "selectors": [ |
| 48 | + { |
| 49 | + "type": "List", |
| 50 | + "targets": [ |
| 51 | + { |
| 52 | + "id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_network_delay_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh", |
| 53 | + "type": "ChaosTarget" |
| 54 | + } |
| 55 | + ], |
| 56 | + "id": "Selector1" |
| 57 | + } |
| 58 | + ], |
| 59 | + "steps": [ |
| 60 | + { |
| 61 | + "name": "AKS network latency", |
| 62 | + "branches": [ |
| 63 | + { |
| 64 | + "name": "AKS network latency", |
| 65 | + "actions": [ |
| 66 | + { |
| 67 | + "type": "continuous", |
| 68 | + "selectorId": "Selector1", |
| 69 | + "duration": "PT5M", |
| 70 | + "parameters": [ |
| 71 | + { |
| 72 | + "key": "jsonSpec", |
| 73 | + "value": "{\"action\":\"delay\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"delay\":{\"latency\":\"200ms\",\"correlation\":\"100\",\"jitter\":\"0ms\"}}" |
| 74 | + } |
| 75 | + ], |
| 76 | + "name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.1" |
| 77 | + } |
| 78 | + ] |
| 79 | + } |
| 80 | + ] |
| 81 | + } |
| 82 | + ] |
| 83 | + } |
| 84 | +} |
| 85 | +
|
| 86 | +``` |
| 87 | + |
| 88 | + |
| 89 | +### [Azure portal parameters](#tab/azure-portal) |
| 90 | + |
| 91 | +```Azure portal |
| 92 | +{"action":"delay","mode":"all","selector":{"namespaces":["default"]},"delay":{"latency":"200ms","correlation":"100","jitter":"0ms"}} |
| 93 | +``` |
| 94 | +--- |
| 95 | +Azure Kubernetes Service (AKS) Pod Failure |
| 96 | +--- |
| 97 | + |
| 98 | +### [Azure CLI](#tab/azure-CLI) |
| 99 | +```AzCLI |
| 100 | +PUT https://management.azure.com/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment?api-version=2024-01-01 |
| 101 | +
|
| 102 | +{ |
| 103 | +
|
| 104 | +"identity": { |
| 105 | + "type": "SystemAssigned", |
| 106 | + "principalId": "35g5795t-8sd4-5b99-a7c8-d5asdh9as7", |
| 107 | + "tenantId": "asd79ash-7daa-95hs-0as8-f3md812e3md" |
| 108 | + }, |
| 109 | + "tags": {}, |
| 110 | + "location": "westus", |
| 111 | + "properties": { |
| 112 | + "provisioningState": "Succeeded", |
| 113 | + "selectors": [ |
| 114 | + { |
| 115 | + "type": "List", |
| 116 | + "targets": [ |
| 117 | + { |
| 118 | + "id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_pod_fail_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh", |
| 119 | + "type": "ChaosTarget" |
| 120 | + } |
| 121 | + ], |
| 122 | + "id": "Selector1" |
| 123 | + } |
| 124 | + ], |
| 125 | + "steps": [ |
| 126 | + { |
| 127 | + "name": "AKS pod kill", |
| 128 | + "branches": [ |
| 129 | + { |
| 130 | + "name": "AKS pod kill", |
| 131 | + "actions": [ |
| 132 | + { |
| 133 | + "type": "continuous", |
| 134 | + "selectorId": "Selector1", |
| 135 | + "duration": "PT5M", |
| 136 | + "parameters": [ |
| 137 | + { |
| 138 | + "key": "jsonSpec", |
| 139 | + "value": "{\"action\":\"pod-failure\",\"mode\":\"all\",\"duration\":\"600s\",\"selector\":{\"namespaces\":[\"autoinstrumentationdemo\"]}}}" |
| 140 | + } |
| 141 | + ], |
| 142 | + "name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:podChaos/2.1" |
| 143 | + } |
| 144 | + ] |
| 145 | + } |
| 146 | + ] |
| 147 | + } |
| 148 | + ] |
| 149 | + } |
| 150 | +} |
| 151 | +
|
| 152 | +``` |
| 153 | + |
| 154 | + |
| 155 | +### [Azure portal parameters](#tab/azure-portal) |
| 156 | + |
| 157 | +```Azure portal |
| 158 | +{"action":"pod-failure","mode":"all","duration":"600s","selector":{"namespaces":["autoinstrumentationdemo"]}} |
| 159 | +``` |
| 160 | +--- |
| 161 | +Azure Kubernetes Service (AKS) Memory Stress |
| 162 | +--- |
| 163 | + |
| 164 | +### [Azure CLI](#tab/azure-CLI) |
| 165 | +```AzCLI |
| 166 | +PUT https://management.azure.com/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment?api-version=2024-01-01 |
| 167 | +
|
| 168 | +{ |
| 169 | +
|
| 170 | +"identity": { |
| 171 | + "type": "SystemAssigned", |
| 172 | + "principalId": "35g5795t-8sd4-5b99-a7c8-d5asdh9as7", |
| 173 | + "tenantId": "asd79ash-7daa-95hs-0as8-f3md812e3md" |
| 174 | + }, |
| 175 | + "tags": {}, |
| 176 | + "location": "westus", |
| 177 | + "properties": { |
| 178 | + "provisioningState": "Succeeded", |
| 179 | + "selectors": [ |
| 180 | + { |
| 181 | + "type": "List", |
| 182 | + "targets": [ |
| 183 | + { |
| 184 | + "id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_memory_stress_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh", |
| 185 | + "type": "ChaosTarget" |
| 186 | + } |
| 187 | + ], |
| 188 | + "id": "Selector1" |
| 189 | + } |
| 190 | + ], |
| 191 | + "steps": [ |
| 192 | + { |
| 193 | + "name": "AKS memory stress", |
| 194 | + "branches": [ |
| 195 | + { |
| 196 | + "name": "AKS memory stress", |
| 197 | + "actions": [ |
| 198 | + { |
| 199 | + "type": "continuous", |
| 200 | + "selectorId": "Selector1", |
| 201 | + "duration": "PT10M", |
| 202 | + "parameters": [ |
| 203 | + { |
| 204 | + "key": "jsonSpec", |
| 205 | + "value": "{\"mode\":\"all\",\"selector\":{\"namespaces\":[\"autoinstrumentationdemo\"]},\"stressors\":{\"memory\":{\"workers\":4,\"size\":\"95%\"}}" |
| 206 | + } |
| 207 | + ], |
| 208 | + "name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:stressChaos/2.1" |
| 209 | + } |
| 210 | + ] |
| 211 | + } |
| 212 | + ] |
| 213 | + } |
| 214 | + ] |
| 215 | + } |
| 216 | +} |
| 217 | +
|
| 218 | +``` |
| 219 | + |
| 220 | + |
| 221 | +### [Azure portal parameters](#tab/azure-portal) |
| 222 | + |
| 223 | +```Azure portal |
| 224 | +{"mode":"all","selector":{"namespaces":["autoinstrumentationdemo"]},"stressors":{"memory":{"workers":4,"size":"95%"}} |
| 225 | +``` |
| 226 | +--- |
0 commit comments