> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/gcp.md). Agents can also search and read this documentation through its [MCP server](https://developer.harness.io/~gitbook/mcp).

# GCP

GCP chaos faults that stop Compute Engine VMs, detach persistent disks, and fail over Cloud SQL instances.

GCP faults act on Google Cloud resources through the Compute Engine and Cloud SQL APIs. The faults run on a Kubernetes chaos infrastructure, which can sit in GKE or in any cluster that can reach the Google Cloud APIs.

***

## Before you begin

* **Chaos infrastructure:** A Kubernetes chaos infrastructure that can reach the Google Cloud API endpoints (`compute.googleapis.com`, `sqladmin.googleapis.com`). Go to [Get started](https://developer.harness.io/resilience-testing/chaos-testing/get-started.md) to install one.
* **Authentication:** The faults need a Google service account, either as a key in a Harness file secret or through Workload Identity on GKE. Go to [GCP fault authentication](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/gcp/authentication.md) to set one up.
* **Permissions:** The service account needs the IAM permissions each fault uses in the target project. Go to [GCP fault permissions](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/gcp/permissions.md) for the combined role.
* **Project and zones:** Each fault sets the target project in `GCP_PROJECT_ID`. VM and disk faults also set the zones of their targets in `ZONES`.

***

## Supported environments

GCP faults target resources in any Google Cloud region. A fault page lists any environment below that it does not support.

| Environment                                                                | Faults that target it                                                         |
| -------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| Compute Engine VMs of any machine type, including Spot and preemptible VMs | VM instance stop faults                                                       |
| GKE Standard worker nodes in managed instance groups                       | VM instance stop faults. GKE Autopilot nodes are not supported.               |
| Non-boot zonal and regional persistent disks                               | VM disk loss faults. Boot disks and Local SSD are not supported.              |
| Cloud SQL for MySQL, PostgreSQL, and SQL Server with high availability     | SQL instance failover. Instances without high availability are not supported. |

***

## Faults

| Fault                                                                                                                                            | What it does                                                | Failure type | Reversible |
| ------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- | ------------ | ---------- |
| [GCP SQL instance failover](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/gcp/gcp-sql-instance-failover.md)         | Fails a Cloud SQL instance over to its standby              | State        | No         |
| [GCP VM disk loss](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/gcp/gcp-vm-disk-loss.md)                           | Detaches persistent disks selected by name                  | Storage      | Yes        |
| [GCP VM disk loss by label](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/gcp/gcp-vm-disk-loss-by-label.md)         | Detaches a percentage of persistent disks selected by label | Storage      | Yes        |
| [GCP VM instance stop](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/gcp/gcp-vm-instance-stop.md)                   | Stops VM instances selected by name                         | State        | Yes        |
| [GCP VM instance stop by label](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/gcp/gcp-vm-instance-stop-by-label.md) | Stops a percentage of VM instances selected by label        | State        | Yes        |

***

## Troubleshooting

<details>

<summary>A GCP fault fails with a 403 "Required permission" error</summary>

The service account the fault authenticates as is missing a permission the fault calls in the target project. The error names the permission. Grant a role that includes it, or grant the combined role. Go to [GCP fault permissions](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/gcp/permissions.md) for the permissions each fault needs.

</details>

<details>

<summary>A GCP fault cannot find credentials</summary>

The fault has no file secret set in `GCP_AUTHENTICATION_SECRET`, and the chaos service account is not bound to a Google service account through Workload Identity. Configure one of the two. Go to [GCP fault authentication](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/gcp/authentication.md) for both methods.

</details>

<details>

<summary>A GCP fault reports that an instance or disk was not found</summary>

The resource is in a different project or zone than the fault is looking in. Check `GCP_PROJECT_ID`, and check that `ZONES` lists the zone of each target in the same order as the target names.

</details>

***

## Next steps

* Go to [GCP fault authentication](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/gcp/authentication.md) to give faults access to your project.
* Go to [GCP fault permissions](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/gcp/permissions.md) to grant the permissions the faults use.
* Go to [GCP VM instance stop](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/gcp/gcp-vm-instance-stop.md) to start with the most common GCP fault.

{% @harness-feedback/feedback %}
