Kubernetes To Properties Maven Plugin

A plugin that allows setting build properties from Kubernetes so that they are available for things like jetty:run or quarkus:dev

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.github.stephenc.continuous
ArtifactId

ArtifactId

k2p-maven-plugin
Last Version

Last Version

1.4
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Kubernetes To Properties Maven Plugin
A plugin that allows setting build properties from Kubernetes so that they are available for things like jetty:run or quarkus:dev
Source Code Management

Source Code Management

http://github.com/stephenc/k2p-maven-plugin/tree/master/

Download k2p-maven-plugin

How to add to project

<plugin>
    <groupId>com.github.stephenc.continuous</groupId>
    <artifactId>k2p-maven-plugin</artifactId>
    <version>1.4</version>
</plugin>

Dependencies

compile (9)

Group / Artifact Type Version
org.apache.maven : maven-model jar 3.0.5
org.apache.maven : maven-core jar 3.0.5
org.apache.maven : maven-plugin-api jar 3.0.5
org.codehaus.plexus : plexus-utils jar 2.0.5
org.codehaus.plexus : plexus-container-default jar 1.0-alpha-9
org.apache.commons : commons-exec jar 1.3
com.jayway.jsonpath : json-path jar 2.5.0
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.0
io.kubernetes : client-java jar 10.0.0

Project Modules

There are no modules declared in this project.

Kubernetes To Properties Maven Plugin

A plugin to help you develop locally against a Kubernetes Cluster without needing to copy secrets into your command line environment.

Basic usage

You are running a Maven goal such as jetty:run or quarkus:dev but you want to point at your test cluster, You have permission to access the test cluster’s secrets and configmaps, but having to copy those into the commandline you want to run is tiresome and runs the risk of accidentally pasting them elsewhere.

By adding the k2p-maven-plugin to a profile you can inject the settings you need:

<project>
  <!-- ... -->
  <profiles>
    <profile>
      <id>dev-cluster</id>
      <build>
        <plugins>
          <plugin>
            <groupId>com.github.stephenc.continuous</groupId>
            <artifactId>k2p-maven-plugin</artifactId>
            <configuration>
              <properties>
                <postgresql.user>configmap!://default/database/username</postgresql.user>
                <postgresql.pass>secret!://default/database/password</postgresql.pass>
              </properties>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

Then just enable the profile and run the k2p:inject goal first to set everything up:

$ mvn -P+dev-cluster k2p:inject jetty:run

Proprety sources

The property values are all specified with a prefix to identify the source. The following sources are supported:

value:

Inject the value after the prefix. There are other plugins that can set properties but this can be useful if setting a bunch of properties from Kubernetes

file:

Inject the contents of the named local file. If the file does not exist an empty string will be injected

file!:

Inject the contents of the named local file. If the file does not exist error will be raised

file?:

Inject the contents of the named local file. If the file does not exist nothing will be injected

secret://{namespace}/{name}/{property}

Inject the value of the specific property in the named secret. If the secret does not exist or does not contain the named property an empty string will be injected

secret!://{namespace}/{name}/{property}

Inject the value of the specific property in the named secret. If the secret does not exist or does not contain the named property an error will be raised

secret?://{namespace}/{name}/{property}

Inject the value of the specific property in the named secret. If the secret does not exist or does not contain the named property nothing will be injected

configMap://{namespace}/{name}/{property}

Inject the value of the specific property in the named configMap. If the configMap does not exist or does not contain the named property an empty string will be injected

configMap!://{namespace}/{name}/{property}

Inject the value of the specific property in the named configMap. If the configMap does not exist or does not contain the named property an error will be raised

configMap?://{namespace}/{name}/{property}

Inject the value of the specific property in the named configMap. If the configMap does not exist or does not contain the named property nothing will be injected

Versions

Version
1.4