1
kubectl get pods -n abc
NAME                       READY         STATUS      RESTARTS   AGE
abc-v2-78b59ccc4f-85xgr   0/1     CrashLoopBackOff   27         129m

Facing below error:

> ➜  ~ kubectl logs -f abc-v2-78b59ccc4f-85xgr -n 
Error: Unable to access jarfile abc.jar

I am assuming either jar is not present or required access is missing. Pls guide me here, how to proceed.

Edit 1: As suggested by @howard-roark, Jar is available inside container, getting the same error message.

Edit 2: Check results now with .jar in java command

Edit 4: Ideally there should be only one instance with running status.

Pooja Verma
  • 133
  • 4
  • 14

2 Answers2

2

Kubernetes is a Container Orchestrator. It runs your images as Containers. The error you are showing looks like an application error and not a Kubernetes error. The way I would approach this is:

  1. Check if the jar file your application calls is in your image. You can do this locally by running your image and exec'ing in to see if your jar file that your application runs is there.
docker run -it <image> /bin/bash

Or you can do a similar command via Kubernetes to exec into your pod:

kubectl run -i --tty testjavacontainer --image=<image> -- /bin/bash
  1. If it is there, then I would confirm its path and make sure that my java command is correctly referencing that path. If it is not there, then I would adjust my Dockerfile to ensure it is at the path that my java command expects.

In short, I would approach this as a standard java error, with the nuance that it happens to run in a container.

Howard_Roark
  • 4,088
  • 1
  • 14
  • 24
  • As suggested by you, i can found the jar in container. But getting the same error message. Check Edit 1 in Question for details. – Pooja Verma Oct 07 '20 at 16:10
  • I am stuck at this issue since last 3 days. :-( – Pooja Verma Oct 07 '20 at 16:12
  • In your command it looks like you didn't include .jar at the end -- it looks like you included everything except .jar or am i misreading that? – Howard_Roark Oct 07 '20 at 16:17
  • java -jar -Dspring.profiles.active=dev target/orbis-microservice-0.0.1-SNAPSHOT.jar --server.port=80 --spring.profiles.active=dev This is my jar path in dockerfile. – Pooja Verma Oct 07 '20 at 16:21
  • Right. also it created new pod with status running. Image attached for reference. – Pooja Verma Oct 07 '20 at 16:24
  • Actually the ingress status is still not ready. Even if i am deleting CrashLoopBackOff status pods. New pods are being created with CrashLoopBackOff status. And my server is giving 503. – Pooja Verma Oct 07 '20 at 16:31
  • Ok well you should check the logs of your pod to see your new error and go from there – Howard_Roark Oct 07 '20 at 16:32
  • Running pods logs are not responding and previous one's has the same error. Error: Unable to access jarfile orbis-microservice.jar Check Edit 4. – Pooja Verma Oct 07 '20 at 16:37
  • 1
    Ok I think that this is becoming more of a general troubleshooting question -- I think that the initial error you asked about should be resolved -- I don't see that orbis-microservice.jar, it looks like it has an entirely different name. Anyway hopefully you have a better sense for how to troubleshoot these problems now – Howard_Roark Oct 07 '20 at 16:48
0

If you mount a config-map resource or other volume on top of where the dockerized-application would normally find its .jar file, this will happen. Be sure to mount in a different place, that it wouldn't overwrite a directory in the container.

A good way to troubleshoot is to override the command that is run in the pod to be "sleep infinity." Once the pod is running, run:

kubectl exec -it runningpod -- /bin/sh

... and look around. Also consider running the docker container directly, looking around.

docker run -i --tty --entrypoint=/bin/sh podcontainerimage 
macetw
  • 1,640
  • 1
  • 17
  • 26