英文:
Error: Unable to access jarfile (Kubernetes)
问题
kubectl get pods -n abc
名称 已准备就绪 状态 重启次数 年龄
abc-v2-78b59ccc4f-85xgr 0/1 CrashLoopBackOff 27 129分钟
面对以下错误:
> ➜ ~ kubectl logs -f abc-v2-78b59ccc4f-85xgr -n
错误:无法访问 jar 文件 abc.jar
我假设要么 jar 文件不存在,要么缺少所需访问权限。
请在这里指导我,如何继续。
编辑 1:根据 @howard-roark 的建议,Jar 文件在容器内可用,但仍收到相同的错误消息。
编辑 2:现在使用带有 .jar 的 java 命令检查结果。
编辑 4:理想情况下,应该只有一个具有运行状态的实例。
英文:
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.
答案1
得分: 2
Kubernetes 是一个容器编排器。它将您的镜像作为容器运行。您显示的错误看起来像是应用程序错误,而不是 Kubernetes 错误。我处理这个问题的方式如下:
- 检查应用程序调用的 JAR 文件是否在镜像中。您可以在本地运行镜像并执行进入,以查看应用程序运行的 JAR 文件是否存在。
docker run -it <image> /bin/bash
或者您可以通过 Kubernetes 进行类似的命令,在 Pod 中执行进入:
kubectl run -i --tty testjavacontainer --image=<image> -- /bin/bash
- 如果存在,然后确认其路径,并确保我的 Java 命令正确引用了该路径。如果不存在,则需要调整 Dockerfile,确保它位于我的 Java 命令期望的路径上。
简而言之,我会将其视为一个标准的 Java 错误,只是它恰好在容器中运行。
英文:
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:
- 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
- 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.
答案2
得分: 0
如果您将config-map资源或其他卷挂载到docker化应用程序通常会找到其.jar文件的位置,就会发生这种情况。请确保挂载到一个不同的位置,以免覆盖容器中的目录。
一个很好的排除故障方法是覆盖在pod中运行的命令为"sleep infinity"。一旦pod正在运行,执行以下命令:
kubectl exec -it runningpod -- /bin/sh
...然后四处查看。还可以考虑直接运行docker容器,进行查看。
docker run -i --tty --entrypoint=/bin/sh podcontainerimage
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论