6
votes

We've setup an AWS s3 storage as Helm repo.

But with development going on, more and more package files are uploade to the S3.

We want to cleanup/delete older files in S3, of course, I know we can't directly delete them from S3 as there're some mapping info stored in index.yaml.

I check the helm help, got few information about this. Is there any formal way to delete older helm packages?

6
Have you tried helm delete --purge [relasename] (see docs.helm.sh/helm/#helm-delete)?Marcus Rickert
Thank you for your help. helm delete is delete release in K8s deployment. I want to delete the useless and older helm packages(*.tgz) in the Helm repo, not delete from K8Suser10814765

6 Answers

1
votes

as mentioned in https://chartmuseum.com/docs/#helm-chart-repository

you can use Helm Museum api to do that

e.g.

# curl -XDELETE http://helm.chartrepo.url/api/charts/chart-name/version

please pay attention to the versions, you have to delete it one version per curl hit, means if you have 2 version and want to delete all the version you have to do it per version

# curl -XDELETE http://helm.chartrepo.url/api/charts/chart-name/1.0.1
# curl -XDELETE http://helm.chartrepo.url/api/charts/chart-name/1.0.2

ps: you can search your apps versions by hit

# curl http://helm.chartrepo.url/index.yaml
1
votes

I would recommend you to use the helm-s3 plugin and follow one of the two approaches for keeping your Helm S3 repo clean and up to date:

1 ) use helm s3 delete to delete specific chart version from the repository:

$ helm s3 delete <some-chart> --version X.Y.Z <repo-name>

Notice that both the remote and local repo indexes will be updated automatically.

2 ) Delete the old chart files (.tgz) directly with the S3 API and then run:

$ helm s3 reindex <repo-name>

It will recreate the index in accordance with the charts in the repository.

0
votes

To Extend on VKR's answer, we had packages in our helm s3 repo that were not required and wanted to get rid of them. I took the following approach.

  1. Downloaded the index.yml file from s3 bucket. Removed all the entries for the packages that were not required. Saved the index.yml file locally. Then deleted the index.yml file from the s3 bucket and uploaded the new modified index.yml file to s3.
  2. Deleted all those packages in s3 that were not required and whose entries were removed from index.yml file in step 1.
  3. Cleared the cache directories mentioned in VKR's answer.
  4. Run helm repo update Everything was fine and all the packages that were not required wouldn't appear in the helm search.
0
votes

curl -XDELETE http://helm.chartrepo.url/api/charts/chart-name/chart-name-<version-number>.tgz

If your helm repo requires authorixation curl -u username:password -XDELETE http://helm.chartrepo.url/api/charts/chart-name/chart-name-<version-number>.tgz

curl -u username:password -XDELETE http://helm.chartrepo.url/api/charts/chart-name/chart-name-0.1.0.tgz

We are using artifactory as our helm repo so here's an example curl -u username:password -XDELETE https://ourartifactoryurl/artifactory/myrepo/myhelmchart/myhelmchart-0.1.0.tgz

0
votes

From the documentation https://chartmuseum.com/docs/#helm-chart-repository -DELETE /api/charts// - delete a chart version (and corresponding provenance file)

  1. first find version $ curl - GET http://localhost:8081/api/charts
  2. curl -XDELETE http://localhost:8081/api/charts/samplechart/0.1.0
-1
votes

There is no way to clean old packages using helm. You can use approach from github.

# !/bin/bash
# Remove all files in these directories.
rm -rf ~/.helm/cache/archive/*
rm -rf ~/.helm/repository/cache/*
# Refreash repository configurations
helm repo update
#That's all.
#If you "helm search" next time, you can find newest stable charts in repository