简体   繁体   English

如何将 docker 容器添加到正在运行的 kube.netes pod?

[英]How to add a docker container to a running kubernetes pod?

I have a running multi-container kube.netes pod and I want to add another docker container to this running pod instead of deleting and creating the pod from scratch.我有一个正在运行的多容器 kube.netes pod,我想向这个正在运行的 pod 添加另一个 docker 容器,而不是从头开始删除和创建 pod。

When you make changes to your pod and deploy them, the replication controller will delete the pod and recreate it with the new configuration - that's how Kubernetes works. 当您对Pod进行更改并部署它们时,复制控制器将删除Pod并使用新配置重新创建它-Kubernetes就是这样工作的。

If you're worried about downtime, you can set your Replicas to 5 for example, and enable Rolling Update. 如果您担心停机时间,可以将副本数设置为5,然后启用滚动更新。 This way the pods will be restarted one by one. 这样,吊舱将一个接一个地重新启动。

If your goal is to run an application in this new container, the best way is to simply modify the YAML manifests.如果您的目标是在这个新容器中运行应用程序,最好的方法是简单地修改 YAML 清单。

If your goal is to debug the pod using this container then running a privileged sidecar container with a shared process namespace is a good idea.如果您的目标是使用此容器调试 pod,那么运行具有共享进程命名空间的特权 sidecar 容器是个好主意。 However this can't be done dynamically or during pod runtime since kube.netes pods are immutable.然而,由于 kube.netes pod 是不可变的,因此这不能动态地或在 pod 运行时完成。 One of the options is to ssh into the node and through docker, inject/attach a new container into the process namespace of the existing container.选项之一是将 ssh 插入节点并通过 docker,将新容器注入/附加到现有容器的进程名称空间中。 However k8's will not be able to manage this container effectively and this method is usually not preferred.然而 k8 将无法有效地管理这个容器,这种方法通常不是首选。

This problem is now addressed by a new feature called ephemeral containers.这个问题现在通过称为临时容器的新功能得到解决。 Ephemeral containers are sidecars used for debugging purposes and can be run using a kubectl command.临时容器是用于调试目的的边车,可以使用 kubectl 命令运行。 This feature is already available on newer versions of k8's.此功能已在较新版本的 k8 上可用。

暂无
暂无

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

相关问题 如何检查在 kubernetes pod 的 docker 容器内运行的工人数量? - How to check the number of workers running inside a docker container of kubernetes pod? 如何使用 docker 容器创建 kubernetes pod - how to create kubernetes pod with docker container 如何将 pod/容器创建时间戳 label 添加到 kubernetes docker 容器标签? - How to add pod/container creation timestamp label to kubernetes docker container labels? 如何登录运行在特定Kubernetes容器内的Docker容器并运行test.sh文件? - How do I login into a Docker container running inside the specific Kubernetes pod and run an test.sh file? 如何从使用 KubernetesPodOperator 触发它的 Airflow 主机将卷挂载到运行 docker 容器的 Kubernetes Pod - How to mount a volume to a Kubernetes Pod running a docker container from the Airflow host that triggers it using the KubernetesPodOperator 如何将 Docker 的 `--privileged` 标志添加到 Kubernetes pod 规范容器 YAML 定义 - How can I add the `--privileged` flag of Docker to a Kubernetes pod spec container YAML definition 如何在 Docker 容器和 Kubernetes pod 中获取应用程序指标 - How to get the application metrics in Docker container and Kubernetes pod 如何将卷附加到 kube.netes pod 容器,如 docker? - How to attache a volume to kubernetes pod container like in docker? 从 docker 容器到 kubernetes pod 的端口发布如何工作? - How does port publishing from a docker container to a kubernetes pod work? 如何对在Docker桌面(Kubernetes)中运行的Pod进行HTTP调用 - How to make HTTP call to pod running in Docker Desktop (Kubernetes)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM