A Maven plugin that makes Maven properties available in your Helm Charts. It can be used to automatically package your Helm Chart, render it and upload it to a Chart Museum.
Add the following to your pom.xml
<build>
<plugins>
...
<plugin>
<groupId>com.deviceinsight.helm</groupId>
<artifactId>helm-maven-plugin</artifactId>
<version>2.1.0</version>
<configuration>
<chartName>my-chart</chartName>
<chartRepoUrl>https://kubernetes-charts.storage.googleapis.com/</chartRepoUrl>
<helmVersion>2.13.0</helmVersion>
<strictLint>true</strictLint>
<valuesFile>src/test/helm/my-chart/values.yaml</valuesFile>
</configuration>
<executions>
<execution>
<goals>
<goal>package</goal>
<goal>lint</goal>
<goal>template</goal>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
In the same Maven module, put your helm charts into src/main/helm/<chartName>
. In the Chart.yaml
, you can use the
${artifactId}
and ${project.version}
Maven placeholders. You can also use Maven properties.
An example for a Chart.yaml
is:
apiVersion: v1
description: A Helm chart installing Rubicon
name: ${artifactId}
version: ${project.version}
home: https://gitlab.device-insight.com/deviceinsight/rubicon
maintainers:
- name: Device Insight
url: https://www.device-insight.com
You probably also will adjust the templates/deployment.yaml
so
that the correct docker image is used. An example snippet:
[...]
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}/rubicon:${project.version}"
[...]
Property | Default | Description |
---|---|---|
chartName |
The Maven |
The name of the chart |
chartRepoUrl |
|
The URL of the Chart repository where dependencies are required from and where charts should be published to |
chartRepoUsername |
None |
The username for basic authentication against the chart repo |
chartRepoPassword |
None |
The password for basic authentication against the chart repo |
chartFolder |
|
The location of the chart files (e.g. Chart.yaml). |
skipSnapshots |
|
If true, SNAPSHOT versions will be built, but not deployed. |
helmGroupId |
|
The helm binary |
helmArtifactId |
|
The helm binary |
helmVersion |
None |
The helm binary |
helm.skip |
|
If true, execution will be skipped entirely |
strictLint |
|
If true, linting fails on warnings (see: Lint) |
valuesFile |
None |
|
outputFile |
target/test-classes/helm.yaml |
output file for template goal |
deployAtEnd |
|
If true, the helm chart is deployed at the end of a multi-module Maven build. This option does not make sense for single-module Maven projects. |
Goal packages a chart directory into a chart archive using the helm package command.
Goal examines a chart for possible issues using the helm lint command.
-
A values file can be provided via parameter
valueFile
-
Strict linting can be configured via parameter
strictLint
goal locally renders templates using the helm template command.
-
A values file can be provided via parameter
valueFile
-
An output file can be provided via parameter
outputFile
To use the deployAtEnd
functionality it’s mandatory to put the Helm Maven Plugin configuration in the parent pom.
<build>
<plugins>
...
<plugin>
<groupId>com.deviceinsight.helm</groupId>
<artifactId>helm-maven-plugin</artifactId>
<version>2.1.0</version>
<configuration>
<chartName>my-chart</chartName>
<chartRepoUrl>https://kubernetes-charts.storage.googleapis.com/</chartRepoUrl>
<helmVersion>2.13.0</helmVersion>
<strictLint>true</strictLint>
<valuesFile>src/test/helm/my-chart/values.yaml</valuesFile>
<deployAtEnd>true</deployAtEnd>
</configuration>
<executions>
<execution>
<goals>
<goal>package</goal>
<goal>lint</goal>
<goal>template</goal>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Creating a new release involves the following steps:
-
./mvnw -DenableSshAgent=true jgitflow:release-start jgitflow:release-finish
NoteThe -DenableSshAgent=true
is only necessary, if you cloned the repository via SSH. -
git push origin master
-
git push --tags
-
git push origin develop
In order to deploy the release to Maven Central, you need to create an account at https://issues.sonatype.org and
configure your account in ~/.m2/settings.xml
:
<settings>
<servers>
<server>
<id>ossrh</id>
<username>your-jira-id</username>
<password>your-jira-pwd</password>
</server>
</servers>
</settings>
The account also needs access to the project on Maven Central. This can be requested by another project member.
Then check out the release you want to deploy (git checkout x.y.z
) and run ./mvnw deploy -Prelease
.