I have a buildconfig on OpenShift which fails to build. The output tells me that the server.log file might contain more info. But OpenShift is deleting the build-pod immediately after the run, so I can't access the file.

I'm not quite familar with OpenShift, but there does not seem to be a command to start a pod/container. In the buildConfigs Yaml, there is also nothing that looks like it does the trick. Adding a restartPolicy did not help.

How to get the files contents?

edit1: The postCommit hook of the buildConfig does not run. I set it to

  script: echo POSTCOMMIT-HOOK && cat /home/payara/paasDomain/logs/server.log

Please try to keep your container running inside a build-pod by introducing an artificial never ending task inside it:

  command: ["/bin/bash", "-c", "--"]
  args: ["while true; do sleep 60; done;"]

then just exec to the container inside a pod to analyze internal server.log file with:

kubectl exec pod <pod_name> -c <container_name> -- /bin/bash

I hope it will help you. Please check here also for other methods to keep pod running in Kubernetes.

  • The postCommit hook is not running in my case, I guess it has to do with the image I'm using of which I have no choice (it's a company-internal image). Your link is interesting though. Thanks for that. – sinned Jan 23 '19 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.