Nuta
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować się zalogować lub zmienić katalog.
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować zmienić katalogi.
Ten artykuł zawiera przykłady tworzenia eksperymentów z poziomu wiersza polecenia i przykładów parametrów witryny Azure Portal dla różnych eksperymentów. Możesz skopiować i wkleić następujące polecenia do interfejsu wiersza polecenia lub witryny Azure Portal i edytować je dla określonych zasobów.
Oto przykład, w którym można skopiować i wkleić parametr witryny Azure Portal do:
Aby zapisać jeden z poniższych przykładów "experiment.json", po prostu wpisz nano experiment.json w usłudze Cloud Shell, skopiuj i wklej dowolny z poniższych przykładów eksperymentów, zapisz go (ctrl+o), zamknij polecenie nano (ctrl+x) i uruchom następujące polecenie:
az rest --method put --uri https://management.azure.com/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment?api-version=2024-01-01
Uwaga
Jest to ogólne polecenie, którego można użyć do utworzenia dowolnego eksperymentu z poziomu interfejsu wiersza polecenia platformy Azure
Uwaga
Upewnij się, że eksperyment ma uprawnienia do działania na wszystkich zasobach w eksperymencie. W tych przykładach jest używana wyłącznie tożsamość zarządzana przypisana przez system, ale obsługujemy również tożsamość zarządzaną przypisaną przez użytkownika. Aby uzyskać więcej informacji, zobacz Uprawnienia eksperymentu. Te eksperymenty nie zostaną uruchomione bez udzielenia uprawnień do eksperymentu do uruchomienia w zasobach docelowych.
Wyświetl wszystkie dostępne przypisania ról tutaj , aby określić, które uprawnienia są wymagane dla zasobów docelowych.
Azure Kubernetes Service (AKS) — opóźnienie sieci
Opis eksperymentu Ten eksperyment opóźnia komunikację sieci przez 200 ms
{
"identity": {
"type": "SystemAssigned",
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_network_delay_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network latency",
"branches": [
{
"name": "AKS network latency",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"delay\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"delay\":{\"latency\":\"200ms\",\"correlation\":\"100\",\"jitter\":\"0ms\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) — niepowodzenie zasobnika
Opis eksperymentu Ten eksperyment usuwa wszystkie zasobniki w klastrze przez 10 minut.
{
"identity": {
"type": "SystemAssigned",
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_pod_fail_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS pod kill",
"branches": [
{
"name": "AKS pod kill",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"pod-failure\",\"mode\":\"all\",\"duration\":\"600s\",\"selector\":{\"namespaces\":[\"autoinstrumentationdemo\"]}}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:podChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) — stres pamięci
Opis eksperymentu Ten eksperyment podkreśla pamięć 4 zasobników usługi AKS do 95% przez 10 minut.
{
"identity": {
"type": "SystemAssigned",
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_memory_stress_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS memory stress",
"branches": [
{
"name": "AKS memory stress",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT10M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"mode\":\"all\",\"selector\":{\"namespaces\":[\"autoinstrumentationdemo\"]},\"stressors\":{\"memory\":{\"workers\":4,\"size\":\"95%\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:stressChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) — obciążenie procesora CPU
Opis eksperymentu Ten eksperyment podkreśla użycie procesora CPU czterech zasobników w klastrze usługi AKS do 95%.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_memory_stress_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS CPU stress",
"branches": [
{
"name": "AKS CPU stress",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT10M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"mode\":\"all\",\"selector\":{\"namespaces\":[\"autoinstrumentationdemo\"]},\"stressors\":{\"cpu\":{\"workers\":4,\"load\":95}}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:stressChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) — emulacja sieci
Opis eksperymentu Ten eksperyment stosuje emulację sieci do wszystkich zasobników w określonej przestrzeni nazw, dodając opóźnienie 100 ms i utratę pakietów 0,1% przez 5 minut.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_network_emulation_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network emulation",
"branches": [
{
"name": "AKS network emulation",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"netem\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"netem\":{\"latency\":\"100ms\",\"loss\":\"0.1\",\"correlation\":\"25\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) — partycja sieciowa
Opis eksperymentu Ten eksperyment dzieli sieć dla wszystkich zasobników w określonej przestrzeni nazw, symulując podział sieci w kierunku "do" przez 5 minut.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_partition_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network partition",
"branches": [
{
"name": "AKS network partition",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"partition\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"partition\":{\"direction\":\"to\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) — ograniczenie przepustowości sieci
Opis eksperymentu Ten eksperyment ogranicza przepustowość sieci dla wszystkich zasobników w określonej przestrzeni nazw do 1 mb/s, z dodatkowymi parametrami limitu, buforu, szybkości szczytu i serii przez 5 minut.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_bandwidth_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network bandwidth",
"branches": [
{
"name": "AKS network bandwidth",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"bandwidth\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"bandwidth\":{\"rate\":\"1mbps\",\"limit\":\"50mb\",\"buffer\":\"10kb\",\"peakrate\":\"1mbps\",\"minburst\":\"0\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) — ponowna kolejność pakietów sieciowych
Opis eksperymentu Ten eksperyment zmienia kolejność pakietów sieciowych dla wszystkich zasobników w określonej przestrzeni nazw z przerwą 5 pakietów i procent zmiany kolejności 25% przez 5 minut.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_reorder_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network reorder",
"branches": [
{
"name": "AKS network reorder",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"reorder\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"reorder\":{\"gap\":\"5\",\"reorder\":\"25\",\"correlation\":\"50\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) — utrata pakietów sieciowych
Opis eksperymentu Ten eksperyment symuluje utratę pakietów w wysokości 10% dla wszystkich zasobników w określonej przestrzeni nazw przez 5 minut.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_loss_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network loss",
"branches": [
{
"name": "AKS network loss",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"loss\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"loss\":{\"loss\":\"10\",\"correlation\":\"25\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) — duplikowanie pakietów sieciowych
Opis eksperymentu Ten eksperyment duplikuje 50% pakietów sieciowych dla wszystkich zasobników w określonej przestrzeni nazw przez 5 minut.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_duplicate_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network duplicate",
"branches": [
{
"name": "AKS network duplicate",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"duplicate\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"duplicate\":{\"duplicate\":\"50\",\"correlation\":\"50\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Azure Kubernetes Service (AKS) — uszkodzenie pakietów sieciowych
Opis eksperymentu Ten eksperyment uszkodzi 50% pakietów sieciowych dla wszystkich zasobników w określonej przestrzeni nazw przez 5 minut.
{
"identity": {
"type": "SystemAssigned"
},
"tags": {},
"location": "westus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/aks_corrupt_experiment/providers/Microsoft.ContainerService/managedClusters/nikhilAKScluster/providers/Microsoft.Chaos/targets/Microsoft-AzureKubernetesServiceChaosMesh",
"type": "ChaosTarget"
}
],
"id": "Selector1"
}
],
"steps": [
{
"name": "AKS network corrupt",
"branches": [
{
"name": "AKS network corrupt",
"actions": [
{
"type": "continuous",
"selectorId": "Selector1",
"duration": "PT5M",
"parameters": [
{
"key": "jsonSpec",
"value": "{\"action\":\"corrupt\",\"mode\":\"all\",\"selector\":{\"namespaces\":[\"default\"]},\"corrupt\":{\"corrupt\":\"50\",\"correlation\":\"50\"}}"
}
],
"name": "urn:csci:microsoft:azureKubernetesServiceChaosMesh:networkChaos/2.2"
}
]
}
]
}
]
}
}
Test obciążeniowy platformy Azure — uruchamianie/zatrzymywanie testu obciążeniowego (z opóźnieniem)
Opis eksperymentu Ten eksperyment rozpoczyna istniejący test obciążeniowy platformy Azure, a następnie czeka 10 minut przy użyciu akcji "opóźnienie" przed zatrzymaniem testu obciążeniowego.
{
"identity": {
"type": "SystemAssigned",
},
"tags": {},
"location": "eastus",
"properties": {
"selectors": [
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/nikhilLoadTest/providers/microsoft.loadtestservice/loadtests/Nikhil-Demo-Load-Test/providers/Microsoft.Chaos/targets/microsoft-azureloadtest",
"type": "ChaosTarget"
}
],
"id": "66e5124c-12db-4f7e-8549-7299c5828bff"
},
{
"type": "List",
"targets": [
{
"id": "/subscriptions/123hdq8-123d-89d7-5670-123123/resourceGroups/builddemo/providers/microsoft.loadtestservice/loadtests/Nikhil-Demo-Load-Test/providers/Microsoft.Chaos/targets/microsoft-azureloadtest",
"type": "ChaosTarget"
}
],
"id": "9dc23b43-81ca-42c3-beae-3fe8ac80c30b"
}
],
"steps": [
{
"name": "Step 1 - Start Load Test",
"branches": [
{
"name": "Branch 1",
"actions": [
{
"selectorId": "66e5124c-12db-4f7e-8549-7299c5828bff",
"type": "discrete",
"parameters": [
{
"key": "testId",
"value": "ae24e6z9-d88d-4752-8552-c73e8a9adebc"
}
],
"name": "urn:csci:microsoft:azureLoadTest:start/1.0"
},
{
"type": "delay",
"duration": "PT10M",
"name": "urn:csci:microsoft:chaosStudio:TimedDelay/1.0"
}
]
}
]
},
{
"name": "Step 2 - End Load test",
"branches": [
{
"name": "Branch 1",
"actions": [
{
"selectorId": "9dc23b43-81ca-42c3-beae-3fe8ac80c30b",
"type": "discrete",
"parameters": [
{
"key": "testId",
"value": "ae24e6z9-d88d-4752-8552-c73e8a9adebc"
}
],
"name": "urn:csci:microsoft:azureLoadTest:stop/1.0"
}
]
}
]
}
]
}
}
}