<p>Is there a way to use Helm to show available chart updates for installed charts?</p>

<p>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:</p>

<pre><code># 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
</code></pre>

<p>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,</p>

<p>As of August 28th 2022, there is no way of knowing from which repository an already installed helm chart came from.</p>
<p>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.<br />
Examples would be: storing configuration in Source Control, Installing charts as argo apps (if you're using argocd), a combination of both, etc.</p>
<p>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.</p>
<p>Let's say you store all of the helm charts as dependencies of some local chart in your source control.</p>
<p>An example would be a <code>Chart.yaml</code> that looks something like this:</p>
<pre><code>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: &quot;https://somechart.io&quot;
  - name: web-app 
    version: 0.2.2
    repository: &quot;https://myrepo.io&quot;
</code></pre>
<p>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.</p>
<p>An example of a bash script:</p>
<pre><code>#!/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 &quot;repo$iter&quot; $repo &gt; /dev/null 2&gt;&amp;1
    then
        available_version=$(helm search repo &quot;repo$iter/$name&quot; --versions | sed -n '2p' | awk '{print $2}')
        if [ &quot;$available_version&quot; != &quot;$version&quot; ]; 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
</code></pre>
