Kubernetes 101 : The Init container - Initializing your pods -



Since we could run multiples containers inside the same pod, it gives us the possibility to run related containers inside the same unit.

Applications running inside pods might need some initialization steps before they start.
We could bundle all these steps into a container called the init container.
The init container would run in the same pod as the main container it initializes.

For example, some application might need some special permissions to be set for their filesystems, or they might need special users to be created before they start.
We may also want to wait for another application to start, before we start our own.

For all the above tasks, we could use the init containers.
Init containers also allow us to keep the main task of the application and the initialization process separate.


The main container waits for the init container to successfully exit before starting its tasks.


We create our pod using the below command:


Our pod start a debian image and sleeps. When the debian image exits, the nginx container takes over.

Comments

Leave as a comment:

Archive