Git Product home page Git Product logo

helmrepo-maven-plugin's Introduction

helmrepo-maven-plugin

Use maven repository to store helm charts. This has three goals:

  1. Package helm chart and add as a secondary artifact for build
  2. Upgrade (install) helm chart release(s)
  3. Uninstall helm chart release(s)

Rationale

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

Plugin reports available at plugin info.

Upgrade Goal

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.

Global Configuration

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

Per-Release Configuration

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

Chart Name

A chart name can be any of the following:

  1. Maven GAV coordinate: org.honton.chas:test-reports:1.3.4
  2. URL: https://​repo.maven.apache.org/maven2/org/honton/chas/test-reports/1.3.4/test-reports-1.3.4.tgz
  3. Path to an unpacked chart directory: src/helm/superfantastic
  4. Path to a packaged chart: superfantastic-44.12.3.tgz
  5. Chart reference: repository/chartname
  6. OCI registry URL: oci://example.com/charts/nginx

Service NodePorts

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.

Uninstall Goal

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.

Pod logs

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.

Template Goal

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

Package Goal

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.

Configuration

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}

Helm Chart Name Limitations

The chart within helmDir must equal ${project.artifactId}.

tgz Packaging Extension

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.

Examples

Typical Use

<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>

Use as a packaging extension

<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>

Common Errors

Incorrectly Named Chart

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]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.