Skip to main content
TopMiniSite

Back to all posts

How to Delete A Helm Release?

Published on
4 min read

Table of Contents

Show more
How to Delete A Helm Release? image

To delete a Helm release, you can follow these steps:

  1. Determine the name of the release you want to delete. You can use the command helm list to see all the releases and their names.
  2. Run the command helm delete RELEASE_NAME, where RELEASE_NAME is the name of the release you want to delete. This command will send a delete request to Kubernetes, which will remove all the resources associated with the release.
  3. By default, Helm will mark the release for deletion and remove the resources in the background. You can use the --purge flag to delete the release and its associated resources immediately. For example, helm delete --purge RELEASE_NAME.
  4. You can verify the deletion of the release by running helm list again. If the release is not listed, it has been successfully deleted.
  5. If you want to delete all the releases in a namespace, you can use the helm delete --purge --all command. This will delete all releases in the current namespace.

Note: Deleting a release does not automatically delete any persistent volumes associated with it. You might need to delete them manually if required.

What is the step-by-step process to delete a Helm release from a Helm repository?

To delete a Helm release from a Helm repository, you can follow the step-by-step process below:

  1. Connect to the Kubernetes cluster where Helm is installed using the kubectl command-line tool.
  2. List all the releases available in the Helm repository by running the following command: helm list
  3. Identify the release you want to delete from the list. Make a note of the release name.
  4. Delete the Helm release by using the helm delete command followed by the release name. Specify the --purge flag to completely remove the release and all its associated resources. The command would look like this: helm delete --purge
  5. Wait for the release to be deleted. You can check the status of the release deletion by running: helm list
  6. Once the release has been successfully deleted, the release will no longer be listed.

Note that deleting a Helm release will also delete all the Kubernetes resources associated with that release, such as pods, services, deployments, etc.

How to delete a Helm release using a YAML manifest file?

To delete a Helm release using a YAML manifest file, you need to create a YAML file specifying the release’s metadata and other required information.

Here are the steps to delete a Helm release using a YAML manifest file:

  1. Create a YAML file, for example "delete-release.yaml", and populate it with the following content:

apiVersion: helm.fluxcd.io/v1 kind: HelmRelease metadata: name: <RELEASE_NAME> namespace: <NAMESPACE_WHERE_RELEASE_IS_INSTALLED> spec: releaseName: <RELEASE_NAME> chart: spec: chart: <CHART_REFERENCE> version: <CHART_VERSION> sourceRef: kind: <SOURCE_KIND> # Kind of the chart source: HelmRepository, GitRepository, or Bucket name: <SOURCE_NAME> # Name of the chart source namespace: <SOURCE_NAMESPACE> # Namespace of the chart source targetNamespace: <NAMESPACE_WHERE_CHART_WAS_INSTALLED>

Replace <RELEASE_NAME> with the name of the release you want to delete. Replace <NAMESPACE_WHERE_RELEASE_IS_INSTALLED> with the namespace where the release is installed. Replace <CHART_REFERENCE> with the reference to the chart you used when installing the release (e.g., "stable/nginx-ingress"). Replace <CHART_VERSION> with the version of the chart you used when installing the release. Replace <SOURCE_KIND>, <SOURCE_NAME>, and <SOURCE_NAMESPACE> with the details of the chart source, such as HelmRepository, GitRepository, or Bucket. Replace <NAMESPACE_WHERE_CHART_WAS_INSTALLED> with the namespace where the original chart was installed.

  1. Save the file.
  2. Run the following kubectl command to delete the Helm release using the YAML manifest:

kubectl apply -f delete-release.yaml

This will apply the manifest file and initiate the deletion of the Helm release.

Note: Make sure you have the necessary permissions to delete the release in the specified namespace.

How to delete a Helm release using the Helm API?

To delete a Helm release using the Helm API, you can follow these steps:

  1. Import the required packages:

import requests import json

  1. Set the necessary variables:

helm_api_url = "http://localhost:8080/helm/api/v1/releases" # Replace with your Helm API URL release_name = "my-release" # Replace with the name of your release

  1. Construct the delete release request:

def construct_delete_release_request(release_name): headers = {"Content-Type": "application/json"} data = { "releaseName": release_name } return headers, json.dumps(data)

  1. Send the delete release request:

def delete_helm_release(api_url, headers, data): response = requests.delete(api_url, headers=headers, data=data) return response.status_code, response.text

  1. Call the functions to delete the release:

headers, data = construct_delete_release_request(release_name) status_code, response_text = delete_helm_release(helm_api_url, headers, data)

print("Status code:", status_code) print("Response:", response_text)

Make sure to replace the helm_api_url variable with the correct URL for your Helm API, and the release_name variable with the name of the release you want to delete.