spotify / dockerfile-maven

MATURE: A set of Maven tools for dealing with Dockerfiles
Apache License 2.0
2.75k stars 493 forks source link

templating kubernetes deployment yaml files #351

Closed scoopex closed 4 years ago

scoopex commented 4 years ago

Description

This is a documentation or feature request. It would be very useful for users of this plugin to have some documentation which describes how to template files (i.e. like a kubernetes deployment yaml file) with parameters configured in this plugin.

We added a configuration like this to your maven configuration:

<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>dockerfile-maven-plugin</artifactId>
    <version>1.4.13</version>
    <executions>
        <execution>
            <id>default</id>
            <goals>
                <goal>build</goal>
                <goal>push</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <snapshotRepository>repo.foobar.baz:15000/repository/docker-release/${docker.image.name}</snapshotRepository>
        <repository>repo.foobar.baz:15001/repository/docker-snapshot/${docker.image.name}</repository>
        <tag>${project.version}</tag>
        <buildArgs>
            <JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
        </buildArgs>
    </configuration>
</plugin>
......
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
        <execution>
            <id>add-resource</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>add-resource</goal>
            </goals>
            <configuration>
                <resources>
                    <resource>
                        <directory>src/main/resources/kubernetes</directory>
                        <filtering>true</filtering>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>

My kubernetes deployment yaml contains hardcoded image uri like this:

      containers:
        - name: productannotator
          image: repo.foobar.baz:15000/repository/docker-release/test/annotator:@project.version@
          env:
            - name: "ARGS"
              value: "--spring.profiles.active=prod"

The question is: Is it possible to use the interpolated docker image reference for templating a file with maven (i suppose it is called "dockerfile.repository"), Which replacement tag do i have to use to use automatically the snapshot or the release tag url? (how can i access the plugin config value "repository")

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.