Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/chonton/helmrepo-maven-plugin

Use Maven repository for helm charts
https://github.com/chonton/helmrepo-maven-plugin

chart helm integration-test kuberenetes maven plugin repository

Last synced: 22 days ago
JSON representation

Use Maven repository for helm charts

Awesome Lists containing this project

README

        

# 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](https://docs.docker.com/desktop/kubernetes/) or
[minikube](https://minikube.sigs.k8s.io/docs/) for integration testing. Build the containers using
[docker-maven-plugin](https://dmp.fabric8.io/), [jib](https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin),
or [buildpacks](https://github.com/paketo-buildpacks/maven). Start k8s pods/deployments/services
during **pre-integration-test** phase. Use [failsafe](https://maven.apache.org/surefire/maven-failsafe-plugin/) 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](https://chonton.github.io/helmrepo-maven-plugin/0.0.3/plugin-info.html).

## Upgrade Goal

The [upgrade](https://chonton.github.io/helmrepo-maven-plugin/0.0.3/upgrade.html) 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](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#service-v1-core)'s metadata. The port
will match either the
[ServicePort](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#serviceport-v1-core)name or port.

## Uninstall Goal

The [uninstall](https://chonton.github.io/helmrepo-maven-plugin/0.0.3/uninstall.html) 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](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#pod-v1-core)'s metadata.

## Template Goal

The [template](https://chonton.github.io/helmrepo-maven-plugin/0.0.3/template.html) goal binds by default to the
**verify** phase. This goal will expand the chart source. Content will be
[filtered](https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html) 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](https://chonton.github.io/helmrepo-maven-plugin/0.0.3/package.html) goal binds by default to the
**package** phase. This goal will create a helm package from the chart source. Content will be
[filtered](https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html) 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](https://maven.apache.org/guides/mini/guide-using-extensions.html) this plugin as an extension.

# Examples

## Typical Use

```xml




org.honton.chas
helmrepo-maven-plugin
0.0.3




org.honton.chas
helmrepo-maven-plugin



package
upgrade
uninstall








org.honton.chas:test-reports:1.3.4




http
report.port
test-reports



test
report



report-job
report
test-reports
src/helm/${project.artifactId}




```

## Use as a packaging extension

```xml

4.0.0

com.example.helm
chart
tgz




org.honton.chas
helmrepo-maven-plugin
0.0.2


```

# Common Errors

## Incorrectly Named Chart

If the **package** goal fails with the following error, your chart directory is probably empty.

```text
[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]
```