After you create a high availability controller, you can manually trigger a failover. For example, you can manually trigger a failover to migrate your workload from the primary zone to the secondary zone, test your workload's behavior during a failover, or return your workload to the original zone after a previous failover.
This document explains how to trigger a failover for a high availability controller. For more information about what happens during a failover, as well as the requirements and limitations that apply, see About high availability controllers.
Before you begin
- Verify that the high availability controller and its secondary zone are
ready for a failover by checking that the
status.readyForFailoverandstatus.zoneStatus.SECONDARY_ZONE.isZoneReadyfields are set totrue. To check these fields, see View the details of a high availability controller. - Verify that the Compute Engine service agent,
service-PROJECT_NUMBER@compute-system., exists in your project and has its default permissions. Otherwise, any attempt to trigger a failover fails. For more information, see Service agents. -
If you haven't already, set up authentication.
Authentication verifies your identity for access to Google Cloud services and APIs. To run
code or samples from a local development environment, you can authenticate to
Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
Install the Google Cloud CLI, and then sign in to the gcloud CLI with your federated identity. After signing in, initialize the Google Cloud CLI by running the following command:
gcloud init - Set a default region and zone.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI, and then sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
-
Required roles
To get the permissions that
you need to trigger a failover for a high availability controller,
ask your administrator to grant you the
Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1) IAM role on the project.
For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the permissions required to trigger a failover for a high availability controller. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to trigger a failover for a high availability controller:
-
To trigger a failover for a high availability controller:
compute.haControllers.failover
You might also be able to get these permissions with custom roles or other predefined roles.
Trigger a failover
After you trigger a failover and the failover completes, the state field
returns to ACTIVE and the status.primaryZone field updates to the new
primary zone. The status.lastFailoverInfo field contains the timestamps and
duration of the failover. To monitor the status of the failover, see
View the details of a high availability controller.
To trigger a failover for a high availability controller, select one of the following options:
Console
In the Google Cloud console, go to the VM instances page.
Click the High availability controllers tab. A pane that shows a list of high availability controllers in your project appears.
Select the row that contains the high availability controller for which you want to trigger a failover. Then, click Initiate failover.
In the Initiate failover window that appears, enter
failover, and then, to confirm, click Failover.
gcloud
To trigger a failover for a high availability controller, use the
gcloud preview compute ha-controllers failover command:
gcloud preview compute ha-controllers failover HA_CONTROLLER_NAME \
--region=REGION \
--failover-to-zone=SECONDARY_ZONE
Replace the following:
HA_CONTROLLER_NAME: the name of the high availability controller.REGION: the region where the high availability controller exists.SECONDARY_ZONE: the secondary zone in the high availability controller where you want to migrate your workload.
REST
To trigger a failover for a high availability controller, make a POST
request to the
preview haControllers.failover method
with the $apiVersion=2026-10-01-preview query parameter in the request
URL:
POST https://compute./compute/v1/projects/PROJECT_ID/regions/REGION/haControllers/HA_CONTROLLER_NAME/failover?$apiVersion=2026-10-01-preview
{
"failoverToZone": "SECONDARY_ZONE"
}
Replace the following:
PROJECT_ID: the ID of your project.REGION: the region where the high availability controller exists.HA_CONTROLLER_NAME: the name of the high availability controller.SECONDARY_ZONE: the secondary zone in the high availability controller where you want to migrate your workload.