I have a ReplicationController containing two containers in a pod, the first is a long-living pod, the second does a few maintenance tasks when the RC starts up a POD. However as the second container is short lived, it stops itself when it finishes its start tasks. When Kuberbetes notices this, it kills off the POD and starts a new one...
What is the correct way to handle this in Kuberbetes?
A ReplicationController manages all the pods with labels that match the selector. It does not distinguish between pods that it created or deleted and pods that another person or process created or deleted. This allows the ReplicationController to be replaced without affecting the running pods. If specified, the .
No more than 300000 total containers.
There are three possible container states: Waiting , Running , and Terminated .
Pod is just a co-located group of container and an Kubernetes object. Instead of deploying them separate you can do deploy a pod of containers . Best practices is that you should not actually run multiple processes via single container and here is the place where pod idea comes to a place.
As you already noticed, by design all containers in a pod are destined to live and die together. It's a bit hard to tell what your best alternative would be without knowing what kind of maintenance task your sidekick needs to perform exactly. Generally speaking, I can think of three approaches:
Keep your maintenance container running. This is probably a fairly ugly solution as it wastes resources. It really only makes sense if the maintenance task can benefit from running periodically.
Move the maintenance task over to your primary container, effectively converting your multi-container pod into a single-container one. I assume that you can run the task asynchronously (as you would already be able to run it in a separate container); if, for some reasons, you cannot, consider modifying readiness and liveness probes accordingly so that your container is given enough time to finish any boot-up procedures before becoming eligible for termination.
Consider adjusting your design so that the maintenance task may run as a separate pod (or maybe even as a job). You'd then need to manage any dependencies and wiring yourself by putting together Kubernetes primitives properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With