For any project currently using Fabric8 Maven Plugin (FMP), migrating to Eclipse JKube should not be that hard.
FMP used to handle both Kubernetes and Openshift clusters but Eclipse JKube has separate plugins for these two different environments.
For any project deploying their applications onto Kubernetes we need proceed Fabric8 Maven Plugin with Eclipse JKube just replacing groupId
and artifactId
like this:
<plugin> <groupId>io.fabric8</groupId> <artifactId>fabric8-maven-plugin</artifactId> <version>4.4.0</version> </plugin>
<plugin> <groupId>org.eclipse.jkube</groupId> <artifactId>k8s-maven-plugin</artifactId> <version>0.1.1</version> </plugin>
In cases where XML configuration is used for enrichers and generators. All the enrichers with prefixes fmp
or f8
are replaced with jkube
. Let's have a look at this example:
<plugin> <groupId>io.fabric8</groupId> <artifactId>fabric8-maven-plugin</artifactId> <version>4.4.0</version> <configuration> <resources> <labels> <all> <testProject>spring-boot-sample</testProject> </all> </labels> </resources> <generator> <includes> <include>spring-boot</include> </includes> <config> <spring-boot> <color>always</color> </spring-boot> </config> </generator> <enricher> <excludes> <exclude>f8-expose</exclude> </excludes> <config> <fmp-service> <type>NodePort</type> </fmp-service> </config> </enricher> </configuration> <executions> <execution> <goals> <goal>resource</goal> <goal>build</goal> <goal>helm</goal> </goals> </execution> </executions> </plugin>
<plugin> <groupId>org.eclipse.jkube</groupId> <artifactId>k8s-maven-plugin</artifactId> <version>0.1.1</version> <configuration> <resources> <labels> <all> <testProject>spring-boot-sample</testProject> </all> </labels> </resources> <generator> <includes> <include>spring-boot</include> </includes> <config> <spring-boot> <color>always</color> </spring-boot> </config> </generator> <enricher> <excludes> <exclude>jkube-expose</exclude> </excludes> <config> <jkube-service> <type>NodePort</type> </jkube-service> </config> </enricher> </configuration> <executions> <execution> <goals> <goal>resource</goal> <goal>build</goal> <goal>helm</goal> </goals> </execution> </executions> </plugin>
If you want to customize Kubernetes manifests added by FMP by means other than XML configuration, you usually add your resources to src/main/fabric8
directory and FMP picks these up during enrichment process and merges them along with the default generated resources.
For Eclipse JKube it's the same, only the src/main/fabric8
directory is replaced withsrc/main/jkube
directory:
[~/work/repos/fabric8-maven-plugin/samples/external-resources]$ ls src/main/fabric8/ deployment.yml sa.yml service.yml
[~/work/repos/jkube/quickstarts/maven/external-resources]$ ls src/main/jkube/ deployment.yml sa.yml service.yml
Projects relying on FMP‘s ImageConfiguration
model for building docker images don’t need any change in Eclipse JKube's XML configuration.
For example, let‘s consider this simple project’s plugin configuration:
<plugin> <groupId>io.fabric8</groupId> <artifactId>fabric8-maven-plugin</artifactId> <version>4.4.0</version> <configuration> <images> <image> <name>rohankanojia/helloworld-java:${project.version}</name> <alias>hello-world</alias> <build> <from>openjdk:latest</from> <assembly> <descriptorRef>artifact</descriptorRef> </assembly> <cmd>java -jar maven/${project.name}-${project.version}.jar</cmd> </build> <run> <wait> <log>Hello World!</log> </wait> </run> </image> </images> </configuration> </plugin>
<plugin> <groupId>org.eclipse.jkube</groupId> <artifactId>k8s-maven-plugin</artifactId> <version>0.1.1</version> <configuration> <images> <image> <name>rohankanojia/helloworld-java:${project.version}</name> <alias>hello-world</alias> <build> <from>openjdk:latest</from> <assembly> <descriptorRef>artifact</descriptorRef> </assembly> <cmd>java -jar maven/${project.name}-${project.version}.jar</cmd> </build> <run> <wait> <log>Hello World!</log> </wait> </run> </image> </images> </configuration> </plugin>
For any project deploying their applications onto Kubernetes we need proceed Fabric8 Maven Plugin with Eclipse JKube just replacing groupId
and artifactId
like this:
<plugin> <groupId>io.fabric8</groupId> <artifactId>fabric8-maven-plugin</artifactId> <version>4.4.0</version> </plugin>
<plugin> <groupId>org.eclipse.jkube</groupId> <artifactId>oc-maven-plugin</artifactId> <version>0.1.1</version> </plugin>
For XML and Resource Fragment configurations, sames rules as for Kubernetes Maven Plugin apply.