我们可以在已经运行的Kubernetes容器中运行可执行的jar文件吗? [英] Can we run an executable jar file inside an already running Kubernetes pod?

查看:69
本文介绍了我们可以在已经运行的Kubernetes容器中运行可执行的jar文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要执行为我的应用程序编写的诊断程序.该应用程序正在Kubernetes容器中运行/部署.我想在Kubernetes容器内复制一个诊断可执行jar文件,并在不停止容器的情况下执行它.如何实现呢?是否存在使用Kubernetes Pod环境就地运行可执行jar的特定方法?

I need to execute a diagnostic program written for my application. The application is running/deployed in a Kubernetes pod. I want to copy a diagnostic executable jar file inside the Kubernetes pod and execute it without stopping the pod. How can this be achieved ? Is there a specific way to run the executable jar using the Kubernetes pod environment in place ?

推荐答案

您可以尝试使用 kubectl cp 命令:

docs :

将/tmp/foo_dir本地目录复制到位于以下位置的远程pod中的/tmp/bar_dir中默认名称空间

Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the default namespace

kubectl cp /tmp/foo_dir <some-pod>:/tmp/bar_dir

将/tmp/foo本地文件复制到特定位置的远程pod中的/tmp/bar容器

Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific container

kubectl cp /tmp/foo <some-pod>:/tmp/bar -c <specific-container>

将/tmp/foo本地文件复制到命名空间中远程pod中的/tmp/bar

Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace

kubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar

将/tmp/foo从远程吊舱复制到本地/tmp/bar

Copy /tmp/foo from a remote pod to /tmp/bar locally

kubectl cp <some-namespace>/<some-pod>:/tmp/foo /tmp/bar

将可执行文件添加到容器中后,您可以 到容器中并手动执行文件.

Once the executable is added inside the container, you can exec into the pod and execute the file manually.

这篇关于我们可以在已经运行的Kubernetes容器中运行可执行的jar文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆