Reputation: 13
I have a running multi-container kubernetes pod and I want to add another docker container to this running pod instead of deleting and creating the pod from scratch.
Upvotes: 0
Views: 874
Reputation: 8824
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 kubernetes 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.
Upvotes: 0
Reputation: 2543
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.
Upvotes: 3