简体   繁体   English

错误:无法访问 jarfile (Kubernetes)

[英]Error: Unable to access jarfile (Kubernetes)

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.我假设 jar 不存在或缺少所需的访问权限。 Pls guide me here, how to proceed.请在这里指导我,如何进行。

Edit 1: As suggested by @howard-roark, Jar is available inside container, getting the same error message.编辑 1:正如@howard-roark 所建议的,Jar 在容器内可用,得到相同的错误消息。

Edit 2: Check results now with .jar in java command编辑 2:在 java 命令中使用 .jar 现在检查结果

Edit 4: Ideally there should be only one instance with running status.编辑 4:理想情况下应该只有一个处于运行状态的实例。

Kubernetes is a Container Orchestrator. Kubernetes 是一个容器编排器。 It runs your images as Containers.它将您的图像作为容器运行。 The error you are showing looks like an application error and not a Kubernetes error.您显示的错误看起来像是应用程序错误,而不是 Kubernetes 错误。 The way I would approach this is:我处理这个问题的方法是:

  1. Check if the jar file your application calls is in your image.检查您的应用程序调用的 jar 文件是否在您的映像中。 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.您可以通过运行您的图像并在其中执行以查看您的应用程序运行的 jar 文件是否在那里来在本地执行此操作。
docker run -it <image> /bin/bash

Or you can do a similar command via Kubernetes to exec into your pod:或者您可以通过 Kubernetes 执行类似的命令来执行到您的 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.如果它在那里,那么我会确认它的路径并确保我的 java 命令正确引用了该路径。 If it is not there, then I would adjust my Dockerfile to ensure it is at the path that my java command expects.如果它不存在,那么我会调整我的 Dockerfile 以确保它在我的 java 命令期望的路径上。

In short, I would approach this as a standard java error , with the nuance that it happens to run in a container.简而言之,我会将其视为标准的 java 错误,其细微差别恰好是在容器中运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM