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 permissionssection:
Required permissions
The following permissions are required to delete a cluster:
- Delete a cluster permission on the cluster:
managedkafka.clusters.delete - List all clusters permission on the location containing the cluster.This permission is only required when deleting clusters using the Google Cloud:
managedkafka.clusters.list
You might also be able to get these permissions with custom roles or other 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 Clusterspage.
-
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 deletecommand:gcloud managed-kafka clusters delete CLUSTER_ID \ --location = LOCATIONReplace the following:
- CLUSTER_ID : The ID or name of the cluster.
- LOCATION : The location of the cluster.
REST
Before using any of the request data, make the following replacements:
-
PROJECT_ID: your Google Cloud project ID -
LOCATION: the location of the cluster -
CLUSTER_ID: the ID of the cluster
HTTP method and URL:
DELETE https://managedkafka.googleapis.com/v1/projects/ PROJECT_ID /locations/ LOCATION /clusters/ CLUSTER_ID
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
{ "name": "projects/ PROJECT_ID /locations/ LOCATION /operations/ OPERATION_ID ", "metadata": { "@type": "type.googleapis.com/google.cloud.managedkafka.v1.OperationMetadata", "createTime": " CREATE_TIME ", "target": "projects/ PROJECT_ID /locations/ LOCATION /clusters/ CLUSTER_ID ", "verb": "delete", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
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 .

