helm-maven-plugin
helm-maven-plugin copied to clipboard
When uploading a chart, all contained subcharts are also explicitly uploaded - bug or feature? Can it be turned off?
We have currently have two helm charts, for each we have our own Maven module. In our build process, we include the first Helm chart (let's name it "x") as a subchart into the second Helm chart (let's name it "y"), by specifying "x" as a dependency of "y" and using the assembly plugin. The result is two artifacts: the Helm chart "y" and the Helm chart "y" with included subchart "x". So far, we simply ZIPPed them both and distributed them manually.
Now we want to host our own internal Helm chart repo and want to deploy the Helm charts into it with every build. So we started testing this maven plugin.
We added this plugin section to the POM of module "y":
<plugin>
<groupId>com.kiwigrid</groupId>
<artifactId>helm-maven-plugin</artifactId>
<version>5.1</version>
<executions>
<execution>
<id>package-chart</id>
<phase>package</phase>
<goals>
<goal>package</goal>
</goals>
</execution>
<execution>
<id>deploy-chart</id>
<phase>install</phase>
<goals>
<goal>upload</goal>
</goals>
</execution>
</executions>
<configuration>
<chartDirectory>${project.basedir}/target/helmchart-y-${project.version}</chartDirectory>
<chartVersion>99.0.1-0-SNAPSHOT</chartVersion>
<uploadRepoStable>
<name>my-local-chartmuseum</name>
<url>http://localhost:8080/api/charts</url>
<type>CHARTMUSEUM</type>
<username>admin</username>
<password>*************</password>
</uploadRepoStable>
<useLocalHelmBinary>true</useLocalHelmBinary>
<autoDetectLocalHelmBinary>false</autoDetectLocalHelmBinary>
<helmExecutableDirectory>C:\Program Files\Helm</helmExecutableDirectory>
</configuration>
</plugin>
In case you are wondering: we only moved the upload goal to the "install" phase for local testing before putting this into our builds.
Also note that we overwrite the chartVersion, the actual version that is in Chart.yaml is 99.0.0.0-SNAPSHOT (don't ask ;-)) This now sortof works, but the behavior is strange.
We observed that the following charts are uploaded:
[INFO] Uploading c:\[...]\helm_y\target\helm\repo\X-99.0.0-0-SNAPSHOT.tgz...
[INFO] 201 - {"saved":true}
[INFO] Uploading c:\[...]\helm_y\target\helm\repo\X-99.0.1-0-SNAPSHOT.tgz...
[INFO] 201 - {"saved":true}
[INFO] Uploading c:\[...]\helm_y\target\helm\repo\Y-99.0.0-0-SNAPSHOT.tgz...
[INFO] 201 - {"saved":true}
[INFO] Uploading c:\[...]\helm_y\target\helm\repo\Y-99.0.1-0-SNAPSHOT.tgz...
[INFO] 201 - {"saved":true}
Note that both the "y" and the "x" chart are being uploaded, although we only activated the helm-maven-plugin in the POM of "y". I can only assume that "x" is uploaded because it is contained as subchart inside "y". Further, both Helm charts are uploaded twice, once with the chartVersion that we specified in the plugin config, and once more with a version that is neither the chartVersion, nor the version in Chart.yaml.
Is this behavior intentional? What is the rationale behind it? In perspective, we want to use the plugin for both "x" and "y", but the deployment of "y" would redeploy "x" as a side-effect.
Seems that at least the upload with the strange version number 99.0.0-0 was caused by our configuration not doing the "init" phase of the plugin. Once I add
<execution>
<id>init-chart</id>
<phase>compile</phase>
<goals>
<goal>init</goal>
</goals>
</execution>
only two uploads happen:
[INFO] Uploading c:\[...]\helm_y\target\helm\repo\X-99.0.1-0-SNAPSHOT.tgz...
[INFO] 201 - {"saved":true}
[INFO] Uploading c:\[...]\helm_y\target\helm\repo\Y-99.0.1-0-SNAPSHOT.tgz...
[INFO] 201 - {"saved":true}
Title edited accordingly
Hi @jgoeres. Actually the plugin should be able to upload several helm charts. Therefor a method exists which collects all related charts (see AbstractHelmMojo#getChartTgzs).
The directory of interest is controlled via property outputDirectory
which is by default ${project.build.directory}/helm/repo
.
Could you please post the content tree of this directory?
It is uploading every .tgz file. So as a workaround created maven-antrun-plugin execution to delete the other charts .tgz and run during phase verify.
Closed as a solution was found.