Use maven repository to store helm charts. This has three goals:
Deploy your containers using helm charts to docker desktop or minikube for integration testing. Build the containers using docker-maven-plugin, jib, or buildpacks. Start k8s pods/deployments/services during pre-integration-test phase. Use failsafe to run integration tests during integration-test phase. Capture logs and uninstall k8s pods/deployments/services during the post-integration-test phase.
Plugin reports available at plugin info.
The upgrade goal binds by default to the
pre-integration-test phase. This goal will execute helm upgrade --install
for each release. If the release name is
not specified, the name will be derived from the chart name.
Parameter | Default | Description |
---|---|---|
kubernetes.context | kubectl default | Name of the kubectl context to use |
kubernetes.createNamespace | true | Create namespaces if not present |
kubernetes.namespace | kubectl context default | Namespace for un-scoped kubernetes resources |
valueFile | - | Yaml values file to be applied during upgrade |
valueYaml | - | Global values to be applied during upgrade, formatted as yaml |
Parameter | Default | Description |
---|---|---|
chart | required | Name of the chart |
logs | - | (uninstall only) Capture logs from specified K8s pods |
name | Un-versioned chart name | Name of the release |
namespace | global namespace | Namespace for un-scoped kubernetes resources |
nodePorts | - | (upgrade only) Set Maven property from specified K8s service/port NodePort |
podLogs | ${project.build.directory}/pods | (uninstall only) Directory to receive pod logs |
requires | - | Comma separated list of releases that must be deployed before this release |
valueYaml | - | Values to be applied to release, formatted as yaml |
wait | 300 | Number of seconds to wait for successful deployment |
A chart name can be any of the following:
Kubernetes has a network mapping of host ports to pod ports. During integration test, we need to use the host port instead of the target port. With NodePort and LoadBalancer service types, the nodePort is unlikely to equal targetPort value. After each release is upgraded, the upgrade goal will set specified maven properties to the assigned nodePort values.
Each element of nodeports is of form [namespace/]name[:port]. The name is required. The namespace and port are optional. The name will match the Service's metadata. The port will match either the ServicePortname or port.
The uninstall goal binds by default to the
post-integration-test phase. This goal will capture the logs from specified pods and execute helm uninstall
for each release. Configuration is similar to the install goal; except the valueYaml, valueFile, and
nodePorts parameters are ignored.
Before uninstalling a release, this goal captures the logs of any specified pods to the podLogs directory. Each element of logs is of form [namespace/]name. The name is required. The namespace is optional. These are used to match the Pod's metadata.
The template goal binds by default to the
verify phase. This goal will expand the chart source. Content will be
filtered using maven properties.
Parameters are same as for the upgrade
goal with the addition of the following:
Parameter | Default | Description |
---|---|---|
templateDir | ${project.build.directory}/helm | Directory for expanded charts |
The package goal binds by default to the package phase. This goal will create a helm package from the chart source. Content will be filtered using maven properties. Resulting .tgz artifact is attached as a secondary artifact for the build. The helm package will be installed in the local maven repository during the install phase and deployed to the remote maven repository during the deploy phase.
Parameter | Default | Description |
---|---|---|
attach | true | Attach helm package as a secondary artifact of the build |
filter | true | Interpolate chart contents, expanding ${variable} expressions |
helmDir | src/helm | Directory holding an unpacked chart named ${project.artifactId} |
The chart within helmDir must equal ${project.artifactId}.
This plugin can also be used as an extension that packages, installs, and deploys the tgz packaging type. Just set the top level element to tgz and register this plugin as an extension.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.honton.chas</groupId>
<artifactId>helmrepo-maven-plugin</artifactId>
<version>0.0.3</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.honton.chas</groupId>
<artifactId>helmrepo-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>package</goal>
<goal>upgrade</goal>
<goal>uninstall</goal>
</goals>
</execution>
</executions>
<configuration>
<valueYaml><![CDATA[
name: globalValue
]]>
</valueYaml>
<releases combine.children="append">
<release>
<chart>org.honton.chas:test-reports:1.3.4</chart>
<valueYaml><![CDATA[
name: releaseValue
nested:
list:
- one
- two
]]>
</valueYaml>
<nodePorts>
<nodePort>
<portName>http</portName>
<propertyName>report.port</propertyName>
<serviceName>test-reports</serviceName>
</nodePort>
</nodePorts>
<logs>
<pod>test</pod>
<pod>report</pod>
</logs>
</release>
<release>
<name>report-job</name>
<namespace>report</namespace>
<requires>test-reports</requires>
<chart>src/helm/${project.artifactId}</chart>
</release>
</releases>
</configuration>
</plugin>
</plugins>
</build>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.helm</groupId>
<artifactId>chart</artifactId>
<packaging>tgz</packaging>
<build>
<extensions>
<extension>
<groupId>org.honton.chas</groupId>
<artifactId>helmrepo-maven-plugin</artifactId>
<version>0.0.2</version>
</extension>
</extensions>
</build>
</project>
If the package goal fails with the following error, your chart directory is probably empty.
[ERROR] Failed to execute goal org.honton.chas:helmrepo-maven-plugin:0.0.3:package (tutorial) on project tutorial: Execution tutorial of goal org.honton.chas:helmrepo-maven-plugin:0.0.3:package failed: archive cannot be empty -> [Help 1]