Reputation: 2308
Is there a way to use Helm to show available chart updates for installed charts?
For example I have a "web-app" chart installed as "test" with version 1.2.4, but in my repo 1.2.7 is available:
# helm ls
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
test default 1 2020-06-04 07:33:07.822952298 +0000 UTC deployed web-app-1.2.4 0.0.1
# helm search repo myrepo
NAME CHART VERSION APP VERSION DESCRIPTION
myrepo/ingress 0.1.0 1.16.0 A Helm chart for Kubernetes
myrepo/sandbox 1.2.3 1.16.0 A Helm chart for Kubernetes
myrepo/web-app 1.2.7 0.0.1 A Helm chart for Kubernetes
My goal is to write a script to send notifications of any charts that need updating so that I can review and run updates. I'd be happy to hear about any devOps style tools that do this,
Upvotes: 6
Views: 3145
Reputation: 1370
Given you have the repositories added, you can use this script to make the upgrade labour easier:
helm list --all-namespaces | awk -F "\t" '{ if (NR != 1) { print "Current version: "$6; system("helm search repo "$1); print "---\n\n" } }'
Upvotes: 0
Reputation: 3399
As of August 28th 2022, there is no way of knowing from which repository an already installed helm chart came from.
If you want to be able to do some sort of automation, currently you need to track the information of which chart came from which repo externally.
Examples would be: storing configuration in Source Control, Installing charts as argo apps (if you're using argocd), a combination of both, etc.
Now since this question doesn't describe the use of any of these methods, I'll just make an assumption and give an example based on of the methods I mentioned.
Let's say you store all of the helm charts as dependencies of some local chart in your source control.
An example would be a Chart.yaml
that looks something like this:
apiVersion: v2
name: chart-of-charts
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
dependencies:
- name: some-chart
version: 0.5.1
repository: "https://somechart.io"
- name: web-app
version: 0.2.2
repository: "https://myrepo.io"
What you could do in this case is traverse through the dependencies and perform a lookup to compare the versions in the .yaml vs versions available.
An example of a bash script:
#!/bin/bash
# requires:
# - helm
# - yq (https://github.com/mikefarah/yq)
chart = Chart.yaml
length=$(yq '.dependencies | length' $chart)
for i in $(seq $length $END); do
iter=$(($i-1))
repo=$(yq .dependencies[$iter].repository $chart)
name=$(yq .dependencies[$iter].name $chart)
version=$(yq .dependencies[$iter].version $chart)
# only if this app points to an external helm chart
if helm repo add "repo$iter" $repo > /dev/null 2>&1
then
available_version=$(helm search repo "repo$iter/$name" --versions | sed -n '2p' | awk '{print $2}')
if [ "$available_version" != "$version" ]; then
echo APP: $(echo $chart | sed 's|/Chart.yaml||')
echo repository: $repo
echo chart name: $name
echo current version: $version Available version: $available_version
echo
fi
fi
done
Upvotes: 3
Reputation: 302
With the command
helm search repo --regexp "myrepo/web-app" --versions
you might get all available versions.
Upvotes: 0