kokuwaio / helm-maven-plugin

Simple plugin to package helm charts
MIT License
82 stars 55 forks source link

Override values in values.yaml (not linting but packaging) #124

Closed Marty closed 2 years ago

Marty commented 3 years ago

FEATURE REQUEST

I'd like the possibility to override the values in the values.yaml that gets packaged in the chart. In my CI/CD scenario I build a bunch of dockerimages and a matching helm chart.

It would be nice to be able to have the correct tag of the new dockerimages already as default in the values.yaml.

Environment (plugin version, maven version, OS, ...): Plugin Version 5.6 Apache Maven 3.6.1 Windows 10

What you expected to happen:

Either some sort of <values><overrides> that gets merged into the values.yaml and isn't just for linting, or maven parameters to be replaced in the values.yaml file.

yauhen-l commented 2 years ago

@Marty You can achieve this with maven resources filtration.

  1. Add chart directory as resources directory and enable filtration for them.
  2. Use ${...} substitutions in your value.yaml which will be processed by maven on resources copying to target directory.
  3. Package chart from target directory, i.e. <chartDirectory>${project.build.outputDirectory}/path/to/chart</chartDirectory>.
jcustenborder commented 2 years ago

This advice worked pretty well for me. I did the following.

           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <executions>
                    <execution>
                        <id>process-helm-resources</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                            <resources>
                                <resource>
                                    <targetPath>${basedir}/target/helm-filtered</targetPath>
                                    <directory>${project.basedir}/src/helm</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>io.kokuwa.maven</groupId>
                <artifactId>helm-maven-plugin</artifactId>
                <version>6.3.0</version>
                <configuration>
                    <chartDirectory>${basedir}/target/helm-filtered</chartDirectory>
                    <chartVersion>${project.version}</chartVersion>
                    <appVersion>${project.version}</appVersion>
                    <useLocalHelmBinary>true</useLocalHelmBinary>
                    <autoDetectLocalHelmBinary>false</autoDetectLocalHelmBinary>
                    <helmExecutableDirectory>/usr/local/bin</helmExecutableDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>helm</id>
                        <phase>package</phase>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
sschnabe commented 2 years ago

Closed because solution exists.