Usage
Generating Kubernetes Files
Add the plugin to your pom:
<build>
<plugins>
....
<plugin>
<groupId>io.github.parj</groupId>
<artifactId>createk8syaml-maven-plugin</artifactId>
<version>0.0.5</version>
<configuration>
<namespace>thisisaspace</namespace>
<image>gcr.io/etc</image>
<path>/foo</path>
<host>localhost</host>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
And then call the plugin:
mvn io.github.parj:createk8syaml-maven-plugin:generate
Parameters
| Parameter Name | Defaults | Description |
|---|---|---|
name |
The name of the project is taken, this is converted to lowercase | The name of the application. By default, the name of the project is taken, this is converted to lowercase and then plugged in |
namespace |
default |
Name of the Kubernetes application to use in the deployment, service and ingress. If not provided, this defaults to default. |
port |
8080 |
The application port to be exposed. If not provided 8080 is exposed by default |
image |
The docker image registry url to use. Example: parjanya/samplespringbootapp | |
path |
The end point of the application to be exposed. Example /foo/bar | |
host |
localhost |
The host for the ingress. If not provided localhost is provided |
readinessProbePath |
Path for the readiness probe for Kubernetes. Ex. /hello/actuator/health. | |
livenessProbePath |
Path for the liveness probe for Kubernetes. Ex. /hello/actuator/customHealthCheck | |
inputDirectory |
The resources directory is the default | The input directory for kubernetes template files |
outputDirectory |
The project build directory is the default | The input directory for directory kubernetes files |
Using with Jib/Fabric/Spotify Docker plugin
If you are using jib or fabric8 or spotify docker plugin, define the docker image name as a variable and then use it both places.
Within the properties section of the pom.xml, define a variable to hold the docker image name
<properties>
<docker.image>docker.io/parjanya/createk8syaml-maven-plugin:0.0.6-SNAPSHOT</docker.image>
</properties>
In the plugin, use it as follows
<plugin>
<groupId>io.github.parj</groupId>
<artifactId>createk8syaml-maven-plugin</artifactId>
<version>0.0.5</version>
<configuration>
<namespace>thisisaspace</namespace>
<image>${docker.image}</image>
<path>/foo</path>
<host>localhost</host>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>createk8syaml</goal>
</goals>
</execution>
</executions>
</plugin>
and if you are using one of the plugins to create the docker image,
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<from>
<image>gcr.io/distroless/java:11</image>
</from>
<to>
<image>${docker.image}</image>
</to>
</configuration>
</plugin>
Deployment of Kubernetes files
<build>
<plugins>
....
<plugin>
<groupId>io.github.parj</groupId>
<artifactId>createk8syaml-maven-plugin</artifactId>
<version>0.0.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
And then call the plugin:
mvn io.github.parj:createk8syaml-maven-plugin:deploy
Parameters
| Parameter Name | Defaults | Description |
|---|---|---|
kubeconfig |
~/.kube/config |
The path to the kuberenetes config file |
context |
Current context within Kubernetes config | The context to use withing the Kubernetes config. Used if you are connecting to a different server that is not the default one |
deployDeployment |
true |
Indicate whether or not to deploy the Kubernetes deployment object |
deployService |
false |
Indicate whether or not to deploy the Kubernetes service object |
deployIngress |
false |
Indicate whether or not to deploy the Kubernetes ingress object |
checkConnection |
true |
If toggled off, there will no connection check before deployment |
filesLocation |
/Users/mudupa/sandbox/createk8syaml-maven-plugin/target/classes |
By default the maven build output directory is picked up |
Kubernetes
For more details on what is a
