<p>I would like a CI pipeline to build an image and a Helm chart. A part of that is of course to set the FQIN of the Helm chart before publishing it.</p>
<p>There are lots of examples on how to do it during installation, but not during packaging. I was surprised that I couldn't find examples on this common use case on <a href="https://helm.sh" rel="nofollow noreferrer">https://helm.sh</a>.
Hand editing the values file of the chart is not an option because it is a CI pipeline.</p>
<p>What is the best practice for doing this without introducing complex CICD tools.</p>

Erik Martino
<p>Your &quot;fully qualified image name&quot; is made up of three parts: a registry host name, the image name itself, and the tag of the image.  I'd recommend passing all three as Helm values, even if only some of them will change.</p>
<pre class="lang-yaml prettyprint-override"><code>image: '{{ .Values.registry }}/{{ .Values.image }}:{{ .Values.tag }}'
</code></pre>
<pre class="lang-yaml prettyprint-override"><code>registry: docker.io
image: my/image
tag: latest
</code></pre>
<p>(When Docker Hub started rate-limiting, I started being really grateful for charts where you could configure the registry address to point at a local mirror.)</p>
<p>Then when you go to actually deploy the image, you need to specify the tag.  In Kubernetes you are all but required to use a unique tag for each build.</p>
<pre class="lang-sh prettyprint-override"><code>docker build -t my/image:20211206 .
docker push my/image:20211206
helm upgrade --install --namespace myapp myapp ./charts/myapp \
  --set-string tag=20211206
</code></pre>
<p>If your CI system can write out JSON files, consider putting the tag and other deploy-time settings into a JSON file and passing that as a <code>helm install -f</code> option, instead of <code>--set</code> or <code>--set-string</code>.  The syntax is much more familiar and you'll have more control over object types when it matters.</p>
<p>There's an alternative approach that involves actually editing the chart as part of the build.  You might have a &quot;GitOps&quot; style workflow where one part of your build system actually commits to source control, and the resulting push triggers the next step.  This has some advantages in that it's easy to verify the file output of one stage, and it's easy to see the history of exactly what got deployed when (because deployment history is source control history).</p>
<p>To do this, your CI system itself would need to change the <code>tag:</code> in <code>values.yaml</code>.  <code>Chart.yaml</code> has an <code>appVersion:</code> setting which can match this, plus if you're making automated changes to the chart itself it's a good idea to increment the chart's <code>version:</code>.  The CI system would make these changes, commit, and push, and then the push would trigger itself to do the next step of deploy.  Since now the right settings are in <code>values.yaml</code> you don't need a <code>--set-string</code> option.</p>
