io.fabric8 在包含 targetDir 配置时生成 Kubernetes 和 Openshift yaml
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>4.3.1</version>
<configuration>
<targetDir>${basedir}/fabric8/</targetDir>
</configuration>
</plugin>
默认情况下,它转到 转到target/fabric8/deployment.yaml
我希望它转到{basedir}/fabric8/
,而不会生成一些额外的额外文件夹和文件,只是/deployment.yaml
,这是我运行的命令mvn fabric8:resource
我来自Fabric8团队。Fabric8 Maven插件有一个选项fabric8.targetDir
您可以使用它覆盖默认目标目录。以下是它应该如何为您的用例工作:
~/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
不幸的是,Fabric8 Maven插件为Kubernetes和Openshift生成资源描述符。在 Kubernetes 的情况下,它也会生成一个默认Service
,如果你想禁用它,你可以像这样配置插件来禁用服务丰富器:
<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>
这样Service
就不会在资源生成阶段生成,你只剩下Deployment
。这是插件配置后的运行:
"/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
我们一直在将FMP重构/重塑为两个不同的插件,你可以在这里找到它:Eclipse Jkube,它有两个插件 - Kubernetes Maven插件和Openshift Maven插件。它们只分别生成 Kubernetes 或 Openshift 清单。这样,您只能生成似乎适合您当前用例的 Kubernetes 资源。
希望有帮助。