To delete a cluster, you can use the Google Cloud console, the Google Cloud CLI, the client libraries, or the Managed Kafka API. You can't use the open source Apache Kafka API to delete a cluster.
Required roles and permissions to delete a cluster
To get the permissions that you need to delete a cluster,
ask your administrator to grant you the
Managed Kafka Cluster Editor (roles/managedkafka.clusterEditor
) IAM role on your project.
For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the permissions required to delete a cluster. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to delete a cluster:
-
Delete a cluster:
managedkafka.clusters.delete
You might also be able to get these permissions with custom roles or other predefined roles.
The Managed Kafka Cluster Editor role does not let you create, delete, or modify topics and consumer groups on Managed Service for Apache Kafka clusters. Nor does it allow data plane access to publish or consume messages within clusters. For more information about this role, see Managed Service for Apache Kafka predefined roles.
Delete a cluster
The following is a list of important considerations before deleting a cluster:
Data loss: Deleting a cluster erases all data stored within it, including topics, messages, configurations, and any other associated resources. This action is irreversible.
Service disruption: Any applications or services that rely on the cluster lose access and experience disruptions. Ensure you have a plan for handling this dependency before deleting the cluster.
Billing: You stop incurring charges for the cluster after it's deleted. However, you might still be billed for resources used up to the point of deletion.
Asynchronous operation: By default, the deletion command operates asynchronously. It returns immediately, and you can track the progress of the deletion separately.
To delete a cluster, follow these steps:
Console
In the Google Cloud console, go to the Cluster page.
- From the list of clusters, select the cluster or clusters that you want to delete.
- Click Delete.
gcloud
-
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
Run the
gcloud managed-kafka clusters delete
command:gcloud managed-kafka clusters delete CLUSTER_ID \ --location=LOCATION
Replace the following:
CLUSTER_ID: The ID or name of the cluster.
-
LOCATION: The location of the cluster.
Go
Before trying this sample, follow the Go setup instructions in Install the client libraries. For more information, see the Managed Service for Apache Kafka Go API reference documentation.
To authenticate to Managed Service for Apache Kafka, set up Application Default Credentials(ADC). For more information, see Set up ADC for a local development environment.
Java
Before trying this sample, follow the Java setup instructions in Install the client libraries. For more information, see the Managed Service for Apache Kafka Java API reference documentation.
To authenticate to Managed Service for Apache Kafka, set up Application Default Credentials. For more information, see Set up ADC for a local development environment.
Python
Before trying this sample, follow the Python setup instructions in Install the client libraries. For more information, see the Managed Service for Apache Kafka Python API reference documentation.
To authenticate to Managed Service for Apache Kafka, set up Application Default Credentials. For more information, see Set up ADC for a local development environment.