简体   繁体   中英

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.

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.

If you're worried about downtime, you can set your Replicas to 5 for example, and enable Rolling Update. 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.

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. However this can't be done dynamically or during pod runtime since kube.netes pods are immutable. 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. However k8's will not be able to manage this container effectively and this method is usually not preferred.

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. This feature is already available on newer versions of k8's.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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