I am building a spring boot java application with maven and fabric8-maven-plugin
for openshift.
The command line I am running is:
mvn -Dfabric8.mode=openshift -Ddocker.skip=true clean install fabric8:resource fabric8:build fabric8:apply -Dfabric8.skipResourceValidation
and I have my openshift deploymentConfig in:
demo/src/main/fabric8/deployment.yml
As a result I would expect that the created deploymentConfig in the namespace my-namespace
would have image triggers like:
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
...
spec:
....
test: false
triggers:
- imageChangeParams:
automatic: true
containerNames:
- demo
from:
kind: ImageStreamTag
name: 'demo:latest'
namespace: my-namespace
type: ImageChange
But it does NOT. Any suggestions to why the image triggers are not created in the generated deployment config?
Some more details below:
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.samples</groupId>
<artifactId>demo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<fabric8-maven-plugin.version>4.4.0</fabric8-maven-plugin.version>
<!--
<fabric8.enricher.fmp-openshift-imageChangeTrigger.enrichAll>true</fabric8.enricher.fmp-openshift-imageChangeTrigger.enrichAll>
<fabric8.openshift.enrichAllWithImageChangeTrigger>true</fabric8.openshift.enrichAllWithImageChangeTrigger>
-->
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>4.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8-maven-plugin.version}</version>
<configuration>
<images>
<image>
<name>${project.artifactId}</name>
<build>
<fromExt>
<name>openjdk18-openshift:1.6-16</name>
<namespace>internal</namespace>
<kind>ImageStreamTag</kind>
</fromExt>
<assembly>
<basedir>/deployments</basedir>
<descriptorRef>rootWar</descriptorRef>
</assembly>
<env>
<JAVA_APP_DIR>/deployments</JAVA_APP_DIR>
</env>
</build>
</image>
</images>
</configuration>
</plugin>
</plugins>
</build>
</project>
demo/src/main/fabric8/deployment.yml
spec:
replicas: 1
strategy:
activeDeadlineSeconds: 21600
recreateParams:
timeoutSeconds: 600
type: Recreate
template:
metadata:
labels:
group: com.samples
project: demo
provider: fabric8
spec:
containers:
- args:
- /usr/local/s2i/run
name: demo
env:
- name: JAVA_APP_JAR
value: /deployments/ROOT.war
src/main/java/com/samples/DemoApplication.java
package com.samples;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
private static final org.slf4j.Logger log = LoggerFactory.getLogger(DemoApplication.class);
private String name = "demoApplicationName";
public String getName() {
return name;
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
This was a bug in Fabric8 Maven Plugin which has been fixed. It's available in
v4.4.1
. We are right now working towards rebranding Fabric8 Maven Plugin to Eclipse JKube. Would appreciate if you could try it out(It's the same as FMP, just without Fabric8 brand name). In future, Fabric8 Maven Plugin would be marked as deprecated in favor of Eclipse JKube. I've created a simple project with your provided code and Eclipse JKube in pom.xml:https://github.com/r0haaaan/fmp-openshift-sample-with-fragments
After running
oc:resource
goal you can see that triggers are now being generated: