Closed rareddy closed 5 years ago
Looks like this is a generic case of #1178 not just spring-boot. If anyone give me code hint, I can submit a PR
@rhuss : Could you please provide some code pointers related to this? In my opinion, ResourceMojo and InitContainerHandler might be good places to look at.
@rareddy @rohanKanojia actually the entry point is probably https://github.com/fabric8io/fabric8-maven-plugin/blob/d359dddc7bcdf6677be9e46cf055ed70fb69254f/enricher/api/src/main/java/io/fabric8/maven/enricher/api/AbstractHealthCheckEnricher.java#L34-L56
Here every container in the list is instrumented with a health check, also for init containers. Not sure whether it can be detected within this visitor what kind of container it is. Also, I guess that health checks for side-car container might not make sense, too.
@nicolaferraro any idea how we could be more selective before adding readiness/liveness probes ?
Yes, the type is the same, so all containers are enriched, no matter their kind. Maybe we should visit at PodSpec
level and distinguish the kind of container. Side-cars should be handled by #1202, so that only the main container is enriched by default. I've to change that PR, I can also try to remove initContainers from the list.
This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!
I think This issue can be fixed via #1202 , but need to update that
Any updates or temporary alternate direction here ?
@wadeholler : We're going to prioritize this, there is a PR already; just needs some refactoring
@rareddy : I think this issue is fixed. Could you please confirm on 4.0.0
?
Its still not fixed in 4.1
@djotanov : Umm, I just checked on one of the samples(spring-boot) using the fragment in src/main/fabric8. I couldn't reproduce the error:
~/work/repos/fabric8-maven-plugin/samples/spring-boot : $ mvn clean install fabric8:deploy
[INFO] Scanning for projects...
[INFO]
[INFO] ------------< io.fabric8:fabric8-maven-sample-spring-boot >-------------
[INFO] Building Fabric8 Maven :: Sample :: Spring Boot Web 4.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ fabric8-maven-sample-spring-boot ---
[INFO] Deleting /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ fabric8-maven-sample-spring-boot ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/src/main/resources
[INFO] skip non existing resourceDirectory /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/src/main/resources
[INFO]
[INFO] --- fabric8-maven-plugin:4.1.0:resource (default) @ fabric8-maven-sample-spring-boot ---
[INFO] F8: Running generator spring-boot
[INFO] F8: spring-boot: Using Docker image fabric8/java-centos-openjdk8-jdk:1.5 as base / builder
[INFO] F8: using resource templates from /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/src/main/fabric8
[INFO] F8: fmp-service: Adding a default service 'fabric8-maven-sample-spring-boot' with ports [8080]
[INFO] F8: fmp-revision-history: Adding revision history limit to 2
[INFO] F8: validating /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/kubernetes/fabric8-maven-sample-spring-boot-service.yml resource
[INFO] F8: validating /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/kubernetes/fabric8-maven-sample-spring-boot-deployment.yml resource
[INFO] F8: using resource templates from /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/src/main/fabric8
[INFO] F8: fmp-service: Adding a default service 'fabric8-maven-sample-spring-boot' with ports [8080]
[INFO] F8: fmp-revision-history: Adding revision history limit to 2
[INFO] F8: validating /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/openshift/fabric8-maven-sample-spring-boot-service.yml resource
[INFO] F8: validating /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/openshift/fabric8-maven-sample-spring-boot-deploymentconfig.yml resource
[INFO] F8: validating /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/openshift/fabric8-maven-sample-spring-boot-route.yml resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ fabric8-maven-sample-spring-boot ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ fabric8-maven-sample-spring-boot ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ fabric8-maven-sample-spring-boot ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ fabric8-maven-sample-spring-boot ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ fabric8-maven-sample-spring-boot ---
[INFO] Building jar: /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/fabric8-maven-sample-spring-boot-4.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.4.1.RELEASE:repackage (default) @ fabric8-maven-sample-spring-boot ---
[INFO]
[INFO] --- fabric8-maven-plugin:4.1.0:build (default) @ fabric8-maven-sample-spring-boot ---
[INFO] F8: Running in Kubernetes mode
[INFO] F8: Building Docker image in Kubernetes mode
[INFO] F8: Running generator spring-boot
[INFO] F8: spring-boot: Using Docker image fabric8/java-centos-openjdk8-jdk:1.5 as base / builder
[INFO] Copying files to /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/docker/fabric8/fabric8-maven-sample-spring-boot/latest/build/maven
[INFO] Building tar: /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/docker/fabric8/fabric8-maven-sample-spring-boot/latest/tmp/docker-build.tar
[INFO] F8: [fabric8/fabric8-maven-sample-spring-boot:latest] "spring-boot": Created docker-build.tar in 203 milliseconds
[INFO] F8: [fabric8/fabric8-maven-sample-spring-boot:latest] "spring-boot": Built image sha256:2b240
[INFO] F8: [fabric8/fabric8-maven-sample-spring-boot:latest] "spring-boot": Removed old image sha256:d27ac
[INFO] F8: [fabric8/fabric8-maven-sample-spring-boot:latest] "spring-boot": Tag with latest
[INFO]
[INFO] --- fabric8-maven-plugin:4.1.0:helm (default) @ fabric8-maven-sample-spring-boot ---
[WARNING] F8: Chart source directory /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/k8s-template does not exist so cannot make chart fabric8-maven-sample-spring-boot. Probably you need run 'mvn fabric8:resource' before.
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ fabric8-maven-sample-spring-boot ---
[INFO] Installing /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/fabric8-maven-sample-spring-boot-4.1-SNAPSHOT.jar to /home/Rohaan/.m2/repository/io/fabric8/fabric8-maven-sample-spring-boot/4.1-SNAPSHOT/fabric8-maven-sample-spring-boot-4.1-SNAPSHOT.jar
[INFO] Installing /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/pom.xml to /home/Rohaan/.m2/repository/io/fabric8/fabric8-maven-sample-spring-boot/4.1-SNAPSHOT/fabric8-maven-sample-spring-boot-4.1-SNAPSHOT.pom
[INFO] Installing /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/kubernetes.yml to /home/Rohaan/.m2/repository/io/fabric8/fabric8-maven-sample-spring-boot/4.1-SNAPSHOT/fabric8-maven-sample-spring-boot-4.1-SNAPSHOT-kubernetes.yml
[INFO] Installing /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/openshift.yml to /home/Rohaan/.m2/repository/io/fabric8/fabric8-maven-sample-spring-boot/4.1-SNAPSHOT/fabric8-maven-sample-spring-boot-4.1-SNAPSHOT-openshift.yml
[INFO]
[INFO] >>> fabric8-maven-plugin:4.1.0:deploy (default-cli) > install @ fabric8-maven-sample-spring-boot >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ fabric8-maven-sample-spring-boot ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/src/main/resources
[INFO] skip non existing resourceDirectory /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/src/main/resources
[INFO]
[INFO] --- fabric8-maven-plugin:4.1.0:resource (default) @ fabric8-maven-sample-spring-boot ---
[INFO] F8: Running generator spring-boot
[INFO] F8: spring-boot: Using Docker image fabric8/java-centos-openjdk8-jdk:1.5 as base / builder
[INFO] F8: using resource templates from /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/src/main/fabric8
[INFO] F8: fmp-service: Adding a default service 'fabric8-maven-sample-spring-boot' with ports [8080]
[INFO] F8: fmp-revision-history: Adding revision history limit to 2
[INFO] F8: validating /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/kubernetes/fabric8-maven-sample-spring-boot-service.yml resource
[INFO] F8: validating /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/kubernetes/fabric8-maven-sample-spring-boot-deployment.yml resource
[INFO] F8: using resource templates from /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/src/main/fabric8
[INFO] F8: fmp-service: Adding a default service 'fabric8-maven-sample-spring-boot' with ports [8080]
[INFO] F8: fmp-revision-history: Adding revision history limit to 2
[INFO] F8: validating /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/openshift/fabric8-maven-sample-spring-boot-service.yml resource
[INFO] F8: validating /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/openshift/fabric8-maven-sample-spring-boot-deploymentconfig.yml resource
[INFO] F8: validating /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/openshift/fabric8-maven-sample-spring-boot-route.yml resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ fabric8-maven-sample-spring-boot ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ fabric8-maven-sample-spring-boot ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ fabric8-maven-sample-spring-boot ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ fabric8-maven-sample-spring-boot ---
[INFO] No tests to run.
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ fabric8-maven-sample-spring-boot ---
[INFO] Building jar: /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/fabric8-maven-sample-spring-boot-4.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.4.1.RELEASE:repackage (default) @ fabric8-maven-sample-spring-boot ---
[INFO]
[INFO] --- fabric8-maven-plugin:4.1.0:build (default) @ fabric8-maven-sample-spring-boot ---
[INFO] F8: Running in Kubernetes mode
[INFO] F8: Building Docker image in Kubernetes mode
[INFO] F8: Running generator spring-boot
[INFO] F8: spring-boot: Using Docker image fabric8/java-centos-openjdk8-jdk:1.5 as base / builder
[INFO] Copying files to /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/docker/fabric8/fabric8-maven-sample-spring-boot/latest/build/maven
[INFO] Building tar: /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/docker/fabric8/fabric8-maven-sample-spring-boot/latest/tmp/docker-build.tar
[INFO] F8: [fabric8/fabric8-maven-sample-spring-boot:latest] "spring-boot": Created docker-build.tar in 141 milliseconds
[INFO] F8: [fabric8/fabric8-maven-sample-spring-boot:latest] "spring-boot": Built image sha256:7763e
[INFO] F8: [fabric8/fabric8-maven-sample-spring-boot:latest] "spring-boot": Removed old image sha256:2b240
[INFO] F8: [fabric8/fabric8-maven-sample-spring-boot:latest] "spring-boot": Tag with latest
[INFO]
[INFO] --- fabric8-maven-plugin:4.1.0:helm (default) @ fabric8-maven-sample-spring-boot ---
[WARNING] F8: Chart source directory /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/k8s-template does not exist so cannot make chart fabric8-maven-sample-spring-boot. Probably you need run 'mvn fabric8:resource' before.
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ fabric8-maven-sample-spring-boot ---
[INFO] Installing /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/fabric8-maven-sample-spring-boot-4.1-SNAPSHOT.jar to /home/Rohaan/.m2/repository/io/fabric8/fabric8-maven-sample-spring-boot/4.1-SNAPSHOT/fabric8-maven-sample-spring-boot-4.1-SNAPSHOT.jar
[INFO] Installing /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/pom.xml to /home/Rohaan/.m2/repository/io/fabric8/fabric8-maven-sample-spring-boot/4.1-SNAPSHOT/fabric8-maven-sample-spring-boot-4.1-SNAPSHOT.pom
[INFO] Installing /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/kubernetes.yml to /home/Rohaan/.m2/repository/io/fabric8/fabric8-maven-sample-spring-boot/4.1-SNAPSHOT/fabric8-maven-sample-spring-boot-4.1-SNAPSHOT-kubernetes.yml
[INFO] Installing /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/openshift.yml to /home/Rohaan/.m2/repository/io/fabric8/fabric8-maven-sample-spring-boot/4.1-SNAPSHOT/fabric8-maven-sample-spring-boot-4.1-SNAPSHOT-openshift.yml
[INFO] Installing /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/kubernetes.yml to /home/Rohaan/.m2/repository/io/fabric8/fabric8-maven-sample-spring-boot/4.1-SNAPSHOT/fabric8-maven-sample-spring-boot-4.1-SNAPSHOT-kubernetes.yml
[INFO] Installing /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/openshift.yml to /home/Rohaan/.m2/repository/io/fabric8/fabric8-maven-sample-spring-boot/4.1-SNAPSHOT/fabric8-maven-sample-spring-boot-4.1-SNAPSHOT-openshift.yml
[INFO]
[INFO] <<< fabric8-maven-plugin:4.1.0:deploy (default-cli) < install @ fabric8-maven-sample-spring-boot <<<
[INFO]
[INFO]
[INFO] --- fabric8-maven-plugin:4.1.0:deploy (default-cli) @ fabric8-maven-sample-spring-boot ---
[INFO] F8: Using Kubernetes at https://192.168.42.184:8443/ in namespace default with manifest /home/Rohaan/work/repos/fabric8-maven-plugin/samples/spring-boot/target/classes/META-INF/fabric8/kubernetes.yml
[INFO] F8: Using namespace: default
[INFO] F8: Updating a Service from kubernetes.yml
[INFO] F8: Updated Service: target/fabric8/applyJson/default/service-fabric8-maven-sample-spring-boot.json
[INFO] F8: Updating Deployment from kubernetes.yml
[INFO] F8: Updated Deployment: target/fabric8/applyJson/default/deployment-fabric8-maven-sample-spring-boot.json
[INFO] F8: HINT: Use the command `kubectl get pods -w` to watch your pods start up
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.915 s
[INFO] Finished at: 2019-05-23T22:09:36+05:30
[INFO] ------------------------------------------------------------------------
ment.yml pos/fabric8-maven-plugin/samples/spring-boot : $ vi target/classes/META-INF/fabric8/kubernetes/fabric8-maven-sample-spring-boot-deploym
yment.yml os/fabric8-maven-plugin/samples/spring-boot : $ cat target/classes/META-INF/fabric8/kubernetes/fabric8-maven-sample-spring-boot-deploy
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
fabric8.io/git-commit: 1bad3dc1b3b0ec58eb9a52832624cf2cf636e4da
fabric8.io/git-branch: pr/removeImageChangeTriggerFlag
fabric8.io/git-url: git@github.com:rohanKanojia/fabric8-maven-plugin.git
fabric8.io/scm-url: https://github.com/spring-projects/spring-boot/spring-boot-starter-parent/fabric8-maven-sample-spring-boot
fabric8.io/scm-tag: HEAD
labels:
app: fabric8-maven-sample-spring-boot
provider: fabric8
version: 4.1-SNAPSHOT
group: io.fabric8
name: fabric8-maven-sample-spring-boot
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
matchLabels:
app: fabric8-maven-sample-spring-boot
provider: fabric8
group: io.fabric8
template:
metadata:
annotations:
fabric8.io/git-commit: 1bad3dc1b3b0ec58eb9a52832624cf2cf636e4da
fabric8.io/git-branch: pr/removeImageChangeTriggerFlag
fabric8.io/scm-tag: HEAD
fabric8.io/git-url: git@github.com:rohanKanojia/fabric8-maven-plugin.git
fabric8.io/scm-url: https://github.com/spring-projects/spring-boot/spring-boot-starter-parent/fabric8-maven-sample-spring-boot
labels:
app: fabric8-maven-sample-spring-boot
provider: fabric8
version: 4.1-SNAPSHOT
group: io.fabric8
spec:
containers:
- env:
- name: JAVA_OPTIONS
value: -Dspring.profiles.active=openshift
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: fabric8/fabric8-maven-sample-spring-boot:latest
imagePullPolicy: IfNotPresent
name: spring-boot
ports:
- containerPort: 8080
name: http
protocol: TCP
- containerPort: 9779
name: prometheus
protocol: TCP
- containerPort: 8778
name: jolokia
protocol: TCP
securityContext:
privileged: false
volumeMounts:
- mountPath: /config
name: config-volume
initContainers:
- command:
- sh
- -c
- echo myProperty=Boo_$DATASOURCE_NAME > /config/application.properties
image: busybox
name: dbmanager
volumeMounts:
- mountPath: /config
name: config-volume
volumes:
- emptyDir:
medium: Memory
name: config-volume
~/work/repos/fabric8-maven-plugin/samples/spring-boot : $ kubectl get pods
NAME READY STATUS RESTARTS AGE
fabric8-maven-sample-spring-boot-5dccf8cf9c-stsjs 1/1 Running 0 103s
fabric8-maven-sample-spring-boot-with-yaml-6fc44fcb5b-8vpv2 0/1 Terminating 1 59d
random-generator-675d9fc49d-66r5b 0/1 Terminating 3 44d
random-generator-675d9fc49d-q2zfv 0/1 Terminating 4 44d
~/work/repos/fabric8-maven-plugin/samples/spring-boot : $
Could you please share a sample project which reproduces this error?
Sorry this feature actually works, I've hit another issue with 4.1: https://github.com/fabric8io/fabric8-maven-plugin/issues/1628
Hmm, I want to get this in too. That issue's author has done good research and I was expecting a PR from him. Let me try to find some time this weekend to send a PR for this :-)
Description
if the template deployment.yml file in the fabric8 directory defines the initContainers the build process generates the liveness and readiness probes in generated openshift.yml and kubernetes.yml files which according to Kubernetes document here is not valid
https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
Currently the deployment fails with error like
Failed to create DeploymentConfig from openshift.yml. io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://192.168.42.122:8443/apis/apps.openshift.io/v1/namespaces/myproject/deploymentconfigs. Message: DeploymentConfig "booster-crud-spring-boot" is invalid: [spec.template.spec.initContainers[0].livenessProbe: Invalid value: core.Probe{Handler:core.Handler{Exec:(*core.ExecAction)(nil),
Info
mvn -v
) : 3.5.0If it's a bug, how to reproduce :