0

io.fabric8 generates kubernetes and openshift yaml when i include targetDir configuration

<plugin>
  <groupId>io.fabric8</groupId>
  <artifactId>fabric8-maven-plugin</artifactId>
  <version>4.3.1</version>
  <configuration>
    <targetDir>${basedir}/fabric8/</targetDir>
  </configuration>
</plugin>

by default it goes to goes to target/fabric8/deployment.yaml i want it to go to {basedir}/fabric8/ without it generating some extra extra folders and files, just /deployment.yaml, this is the command i ran mvn fabric8:resource

vahdet
  • 6,357
  • 9
  • 51
  • 106
Muzi Jack
  • 788
  • 1
  • 7
  • 20

1 Answers1

0

I'm from Fabric8 team. Fabric8 Maven Plugin has an option fabric8.targetDir with which you can override default target directory. Here is how it should work for your use case:

~/work/repos/fmp-demo-project : $ mkdir fabric8
~/work/repos/fmp-demo-project : $ mvn fabric8:resource -Dfabric8.targetDir="./fabric8"
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< meetup:random-generator >-----------------------
[INFO] Building random-generator 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- fabric8-maven-plugin:4.3.1:resource (default-cli) @ random-generator ---
[INFO] F8: Using Container image name of namespace: rokumar
[INFO] F8: Running generator spring-boot
[INFO] F8: spring-boot: Using Container image fabric8/s2i-java:2.3 as base / builder
[INFO] F8: fmp-controller: Adding a default Deployment
[INFO] F8: fmp-service: Adding a default service 'random-generator' with ports [8080]
[INFO] F8: f8-healthcheck-spring-boot: Adding readiness probe on port 8080, path='//health', scheme='HTTP', with initial delay 10 seconds
[INFO] F8: f8-healthcheck-spring-boot: Adding liveness probe on port 8080, path='//health', scheme='HTTP', with initial delay 180 seconds
[INFO] F8: fmp-revision-history: Adding revision history limit to 2
[INFO] F8: validating /home/rohaan/work/repos/fmp-demo-project/fabric8/kubernetes/random-generator-service.yml resource
[INFO] F8: validating /home/rohaan/work/repos/fmp-demo-project/fabric8/kubernetes/random-generator-deployment.yml resource
[INFO] F8: fmp-controller: Adding a default DeploymentConfig
[INFO] F8: fmp-service: Adding a default service 'random-generator' with ports [8080]
[INFO] F8: f8-healthcheck-spring-boot: Adding readiness probe on port 8080, path='//health', scheme='HTTP', with initial delay 10 seconds
[INFO] F8: f8-healthcheck-spring-boot: Adding liveness probe on port 8080, path='//health', scheme='HTTP', with initial delay 180 seconds
[INFO] F8: fmp-revision-history: Adding revision history limit to 2
[INFO] F8: validating /home/rohaan/work/repos/fmp-demo-project/fabric8/openshift/random-generator-deploymentconfig.yml resource
[INFO] F8: validating /home/rohaan/work/repos/fmp-demo-project/fabric8/openshift/random-generator-service.yml resource
[INFO] F8: validating /home/rohaan/work/repos/fmp-demo-project/fabric8/openshift/random-generator-route.yml resource
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.127 s
[INFO] Finished at: 2020-01-08T12:37:50+05:30
[INFO] ------------------------------------------------------------------------
~/work/repos/fmp-demo-project : $ ls fabric8/
kubernetes  kubernetes.yml  openshift  openshift.yml
~/work/repos/fmp-demo-project : $ ls fabric8/kubernetes
random-generator-deployment.yml  random-generator-service.yml

Unfortunately, Fabric8 Maven Plugin generates resource descriptors for both Kubernetes and Openshift. In case of Kubernetes also, it generates a default Service, if you want to disable it, you can configure plugin like this to disable Service Enricher:

            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>fabric8-maven-plugin</artifactId>
                <version>4.3.1</version>
                <configuration>
                   <enricher>
                     <excludes>
                       <exclude>fmp-service</exclude>
                     </excludes>
                   </enricher>
                </configuration>
            </plugin>

This way Service won't be generated during the resource generation phase and you would be left with Deployment only. Here is a run after the plugin configuration:

"/work/repos/fmp-demo-project : $ mvn fabric8:resource -Dfabric8.targetDir="./fabric8 
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< meetup:random-generator >-----------------------
[INFO] Building random-generator 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- fabric8-maven-plugin:4.3.1:resource (default-cli) @ random-generator ---
[INFO] F8: Using Container image name of namespace: rokumar
[INFO] F8: Running generator spring-boot
[INFO] F8: spring-boot: Using Container image fabric8/s2i-java:2.3 as base / builder
[INFO] F8: fmp-controller: Adding a default Deployment
[INFO] F8: f8-healthcheck-spring-boot: Adding readiness probe on port 8080, path='/actuator/health', scheme='HTTP', with initial delay 10 seconds
[INFO] F8: f8-healthcheck-spring-boot: Adding liveness probe on port 8080, path='/actuator/health', scheme='HTTP', with initial delay 180 seconds
[INFO] F8: fmp-revision-history: Adding revision history limit to 2
[INFO] F8: validating /home/rohaan/work/repos/fmp-demo-project/fabric8/kubernetes/random-generator-deployment.yml resource
[INFO] F8: fmp-controller: Adding a default DeploymentConfig
[INFO] F8: f8-healthcheck-spring-boot: Adding readiness probe on port 8080, path='/actuator/health', scheme='HTTP', with initial delay 10 seconds
[INFO] F8: f8-healthcheck-spring-boot: Adding liveness probe on port 8080, path='/actuator/health', scheme='HTTP', with initial delay 180 seconds
[INFO] F8: fmp-revision-history: Adding revision history limit to 2
[INFO] F8: validating /home/rohaan/work/repos/fmp-demo-project/fabric8/openshift/random-generator-deploymentconfig.yml resource
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.598 s
[INFO] Finished at: 2020-01-08T14:20:52+05:30
[INFO] ------------------------------------------------------------------------
~/work/repos/fmp-demo-project : $ ls fabric8/
kubernetes  kubernetes.yml  openshift  openshift.yml
~/work/repos/fmp-demo-project : $ ls fabric8/kubernetes
random-generator-deployment.yml

We have been refactoring/rebranding FMP into two different plugins, you can find it here: Eclipse Jkube, it has two plugins - Kubernetes Maven Plugin and Openshift Maven Plugin. They only generate Kubernetes or Openshift manifests respectively. That way you can only generate Kubernetes resources which seem to be fitting your current use case.

Hope that helps.

Rohan Kumar
  • 5,427
  • 8
  • 25
  • 40
  • if you do a mvn fabric8:resource it generates deployment.yaml file only without the other descriptors, only if you don't have the in your configuration. once you start putting that or -Dfabric8.targetDir u get the descriptors, which im trying to avoid – Muzi Jack Jan 08 '20 at 08:19
  • so if you can check under target folder in a case where you did not specify which directory you want it to go. the folders generated are fabric8/deployment and classes/kubernetes ./openshift . so im only looking for fabric8/deployment which i defined under src/main/fabric8/deployment.yml so it gets copied to target – Muzi Jack Jan 08 '20 at 08:28
  • but once you define your own custom directory the fabric8/deployments.yml get left out – Muzi Jack Jan 08 '20 at 08:29
  • @muzijack: Fabric8 Maven Plugin always generates resource manifests for both Kubernetes and Openshift. If you want kubernetes specific resources only then you might want to try [Kubernetes Maven Plugin](https://search.maven.org/artifact/org.eclipse.jkube/k8s-maven-plugin/0.1.0/maven-plugin). However, by default it generates both `Deployment` and `Service` – Rohan Kumar Jan 08 '20 at 08:50
  • my point is theres one file missing my custom deployment.yml file that doesn't get copied over – Muzi Jack Jan 08 '20 at 08:55
  • Have you checked whether your Custom `deployment.yml` fragment is merged into final `Deployment`. If you have provided it in `src/main/fabric8` directory – Rohan Kumar Jan 08 '20 at 08:59
  • the resource fragment isn't copied by plugin, but it's merged into the final generated manifest – Rohan Kumar Jan 08 '20 at 09:15
  • i want to show you through an email of what i'm experiencing, i want to share screenshots. please share your email address if you don't mind. – Muzi Jack Jan 09 '20 at 08:00
  • rohaan@redhat.com – Rohan Kumar Jan 10 '20 at 11:05