fabric8 maven plugin configuration with image running Java > 8

1.1k views Asked by At

I am using fabric8 maven plugin to deploy a vertx application into Openshift. My application is running with Java 11.

However, by default, the fabric8 maven plugin uses a Java 8 Docker image to create my vertx application image.

How is it possible to configure fabric8 maven plugin to use a Java 11 image ? Does it provide other images for Java > 8 ?

2

There are 2 answers

0
Markus Hettich On BEST ANSWER

I fixed it for my Spring Boot application by adding from configuration to the generator. For vert.x the solution could look like this:

<plugin>                                                     
    <groupId>io.fabric8</groupId>                            
    <artifactId>fabric8-maven-plugin</artifactId>            
    <version>3.5.42</version>                                
    <configuration>                                          
        <generator>                                          
            <config>                                         
                <vertx>                                      
                    <from>fabric8/s2i-java:3.0-java11</from> 
                </vertx>                                     
            </config>                                        
        </generator>                                         
    </configuration>                                         
</plugin>

Which tags are available for the s2i image can be looked up at the Docker Hub page: https://hub.docker.com/r/fabric8/s2i-java/tags

0
Piotr Żak On

for me this solution from above didn't help but thanks of that! I've found out that I've to declare image in my profile definition. I'm running my openshift build like this: mvn clean fabric8:deploy -P openshift What help me a lot was adding this to profile:

  <properties>
      <fabric8.generator.fromMode>docker</fabric8.generator.fromMode>
      <fabric8.generator.from>fabric8/s2i-java:3.0-java11</fabric8.generator.from>
  </properties>

Below part of my pom.xml have a look profile definition

<properties>
    ...
    <java.version>11</java.version>
    <maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version>
    <fabric8-maven-plugin.version>4.4.1</fabric8-maven-plugin.version>
  </properties>

  <dependencies>

  ...

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>${spring.boot.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven.compiler.plugin.version}</version>
        <configuration>
          <release>${java.version}</release>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>openshift</id>
      <properties>
          <fabric8.generator.fromMode>docker</fabric8.generator.fromMode>
          <fabric8.generator.from>fabric8/s2i-java:3.0-java11</fabric8.generator.from>
      </properties>
      <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-kubernetes-dependencies</artifactId>
            <version>0.3.0.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
          </dependency>
          <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Finchley.SR2</version>
            <type>pom</type>
            <scope>import</scope>
          </dependency>
        </dependencies>
      </dependencyManagement>

      <dependencies>
        <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-starter-kubernetes-config</artifactId>
        </dependency>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
      </dependencies>

      <build>
        <plugins>       
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>fabric8-maven-plugin</artifactId>
            <version>${fabric8-maven-plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>resource</goal>
                  <goal>build</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <enricher>
                <config>
                  <f8-healthcheck-vertx>
                    <readiness>
                      <path>/actuator/health</path>
                    </readiness>
                    <liveness>
                      <path>/actuator/health</path>
                    </liveness>
                  </f8-healthcheck-vertx>
                </config>
              </enricher>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>