Leggere in inglese

Condividi tramite


Esempi di esperimenti

Questo articolo fornisce esempi per la creazione di esperimenti dalla riga di comando e portale di Azure esempi di parametri per vari esperimenti. È possibile copiare e incollare i comandi seguenti nell'interfaccia della riga di comando o portale di Azure e modificarli per le risorse specifiche.

Ecco un esempio di dove copiare e incollare il parametro portale di Azure in:

Screenshot che mostra portale di Azure percorso del parametro.

Per salvare uno degli esempi di "experiment.json" illustrati di seguito, digitare semplicemente nano experiment.json in Cloud Shell, copiare e incollare uno degli esempi di esperimento seguenti, salvarlo (ctrl+o), uscire da nano (CTRL+x) ed eseguire il comando seguente:

AzCLI
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

Nota

Questo è il comando generico da usare per creare qualsiasi esperimento dall'interfaccia della riga di comando di Azure

Nota

Assicurarsi che l'esperimento abbia l'autorizzazione per operare su TUTTE le risorse all'interno dell'esperimento. Questi esempi usano esclusivamente l'identità gestita assegnata dal sistema, ma è supportata anche l'identità gestita assegnata dall'utente. Per altre informazioni, vedere Autorizzazioni dell'esperimento. Questi esperimenti non verranno eseguiti senza concedere l'autorizzazione dell'esperimento per l'esecuzione nelle risorse di destinazione.

Visualizzare tutte le assegnazioni di ruolo disponibili qui per determinare quali autorizzazioni sono necessarie per le risorse di destinazione.


servizio Azure Kubernetes (servizio Azure Kubernetes) - Ritardo di rete

Descrizione esperimento Questo esperimento ritarda la comunicazione di rete di 200 ms

AzCLI
{    

"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"
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

servizio Azure Kubernetes (AKS) - Errore del pod

Descrizione esperimento Questo esperimento rimuove tutti i pod nel cluster per 10 minuti.

AzCLI
{    

"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"
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

servizio Azure Kubernetes (servizio Azure Kubernetes) - Stress per la memoria

Descrizione esperimento Questo esperimento sottolinea la memoria di 4 pod del servizio Azure Kubernetes al 95% per 10 minuti.

AzCLI
{    

"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"
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

servizio Azure Kubernetes (servizio Azure Kubernetes) - Stress cpu

Descrizione esperimento Questo esperimento sottolinea la CPU di quattro pod nel cluster del servizio Azure Kubernetes al 95%.

AzCLI
{
    "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"
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

servizio Azure Kubernetes (AKS) - Emulazione di rete

Descrizione esperimento Questo esperimento applica un'emulazione di rete a tutti i pod nello spazio dei nomi specificato, aggiungendo una latenza di 100 ms e una perdita di pacchetti pari allo 0,1% per 5 minuti.

AzCLI
{
    "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"
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

servizio Azure Kubernetes (AKS) - Partizione di rete

Descrizione esperimento Questo esperimento partiziona la rete per tutti i pod nello spazio dei nomi specificato, simulando una divisione di rete nella direzione "a" per 5 minuti.

AzCLI
{
    "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"
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

servizio Azure Kubernetes (AKS) - Limitazione della larghezza di banda di rete

Descrizione esperimento Questo esperimento limita la larghezza di banda di rete per tutti i pod nello spazio dei nomi specificato a 1 MB, con parametri aggiuntivi per limite, buffer, frequenza di picco e burst per 5 minuti.

AzCLI
{
    "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"
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

servizio Azure Kubernetes (AKS) - Riesezione pacchetti di rete

Descrizione esperimento Questo esperimento riordina i pacchetti di rete per tutti i pod nello spazio dei nomi specificato, con una distanza di 5 pacchetti e una percentuale di riordinamento del 25% per 5 minuti.

AzCLI
{
    "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"
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

servizio Azure Kubernetes (AKS) - Perdita di pacchetti di rete

Descrizione esperimento Questo esperimento simula una perdita di pacchetti del 10% per tutti i pod nello spazio dei nomi specificato per 5 minuti.

AzCLI
{
    "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"
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

servizio Azure Kubernetes (AKS) - Duplicazione di pacchetti di rete

Descrizione esperimento Questo esperimento duplica il 50% dei pacchetti di rete per tutti i pod nello spazio dei nomi specificato per 5 minuti.

AzCLI
{
    "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"
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

servizio Azure Kubernetes (AKS) - Danneggiamento dei pacchetti di rete

Descrizione esperimento Questo esperimento danneggia il 50% dei pacchetti di rete per tutti i pod nello spazio dei nomi specificato per 5 minuti.

AzCLI
{
    "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 di carico di Azure - Test di carico di avvio/arresto (con ritardo)

Descrizione esperimento Questo esperimento avvia un test di carico di Azure esistente, quindi attende 10 minuti usando l'azione "ritardo" prima di arrestare il test di carico.

AzCLI
{    

"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"
                            }
                        ]
                    }
                ]
            }
        ]
    }
}
}