Simulate GCP Faults

    GCPChaos is a fault type in Chaos Mesh. By creating a GCPChaos experiment, you can simulate fault scenarios of the specified GCP instance. Currently, GCPChaos supports the following fault types:

    • Node Stop: stops the specified GCP instance.
    • Disk Loss: uninstalls the storage volume from the specified GCP instance.

    To easily connect to the GCP cluster, you can create a Kubernetes Secret file to store the authentication information in advance.

    Below is a sample secret file:

    • name defines the name of kubernetes secret.
    • namespace defines the namespace of kubernetes secret.
    • service_account stores the service account key of your GCP cluster. Remember to complete Base64 encoding for your GCP service account key. To learn more about service account key, see .

    note

    Before you create an experiment using Chaos Dashboard, make sure the following requirements are met:

    1. Chaos Dashboard is installed.

    2. Chaos Dashboard can be accessed using kubectl port-forward command:

      1. kubectl port-forward -n chaos-mesh svc/chaos-dashboard 2333:2333

      Then you can access the dashboard via in your browser.

    3. Open Chaos Dashboard, and click NEW EXPERIMENT on the page to create a new experiment:

    4. In the Choose a Target area, choose GCP fault and select a specific behavior, such as STOP NODE:

      img

    5. Submit the experiment information.

    1. Write the experiment configuration to the gcpchaos-node-stop.yaml, as shown below:

      Based on this configuration example, Chaos Mesh will inject the node-stop fault into the specified GCP instance so that the GCP instance will be unavailable in 5 minutes.

      For more information about stopping GCP instances, refer to Stop GCP instance.

      1. kubectl apply -f gcpchaos-node-stop.yaml
    1. Write the experiment configuration to the gcpchaos-node-reset.yaml, as shown below:

      Based on this configuration example, Chaos Mesh will inject node-reset fault into the specified GCP instance so that the GCP instance will be reset.

      For more information about resetting GCP instances, refer to Resetting a GCP instance.

    2. After the configuration file is prepared, use kubectl to create an experiment:

      1. kubectl apply -f gcpchaos-node-reset.yaml
    1. Write the experiment configuration to the gcpchaos-disk-loss.yaml, as shown below:

      Based on this configuration example, Chaos Mesh will inject a disk-loss fault into the specified GCP instance so that the GCP instance is detached from the specified storage volume within 5 minutes.

      For more information about detaching GCP instances, refer to Detach GCP storage.

    2. After the configuration file is prepared, use kubectl to create an experiment:

      The following table shows the fields in the YAML configuration file.