NOTE We highly recommend you use 3.x or later. We can help you migrate to the new version via the fabric8:migrate goal.
If you wish to stay on the 2.x version then here's the documentation:
For building and pushing docker images
For generating and applying Kubernetes JSON
Goals for working with Kubernetes
fabric8.yml
configuration fileGoals for working with Helm Chart repositories
To enable this maven plugin and to automatically generate/copy and release the App JSON file as part of your build add this to your pom.xml:
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric.version}</version>
<executions>
<execution>
<id>json</id>
<goals>
<goal>json</goal>
</goals>
</execution>
</executions>
</plugin>
To automatically generate an App Zip for your project then add this:
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<id>zip</id>
<phase>package</phase>
<goals>
<goal>zip</goal>
</goals>
</execution>
</executions>
</plugin>
If you use CDI for your dependency injection and use the @ConfigProperty annotation from deltaspike to inject environment variables or default values into your Java code then you can automatically generate a json schema file for each jar you create by just adding a provided scope dependency on the fabric8-apt module.
e.g. add this to your pom.xml
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-apt</artifactId>
<scope>provided</scope>
</dependency>
This will then generate inside your jar a file called io/fabric8/environment/schema.json which will be a JSON Schema document describing all the environment variables, their types, default values and their description (if you added some javadoc for them).
By default any discovered environment variable JSON Schema files will be included in the generated JSON so that your app JSON has all the available known environment variables from a CDI perspective; which makes it easy to change the app without too much detailed knowledge of the source code and helps reduce typeos since all the environment variable names are defaulted.
If you wish to disable this behaviour then set the maven property fabric8.includeAllEnvironmentVariables to false.
If you have transitive dependencies which include the generated io/fabric8/environment/schema.json file in their jars you can view the overall list of environment variable injection points for a project via:
mvn fabric8:describe-env
This will then list all the environment variables, their default value, type and description.
Before deploying you need to make sure your docker image is available to Kubernetes. See above for how to do this. Any docker registry that is accessible to Kubernetes is supported.
To deploy your App Zip into the wiki in the web console use the following goal:
mvn fabric8:deploy
This goal uses the default fabric8 console URL of http://dockerhost:8484/hawtio/ unless you specify the FABRIC8_CONSOLE environment variable to point at something else.
e.g. to try this against a locally running hawtio try:
export FABRIC8_CONSOLE=http://localhost:8282/hawtio/
This goal will then POST the App Zip into the wiki so you should be able to view the newly posted App at http://dockerhost:8484/hawtio/wiki/branch/master/view
To see these plugins in action check out how to run and example quickstart