The postStart hooks:

A postStart hook is set of instructions, that run after a pod is created. The pods stays in a "pending" state until the postStart "programs" exits.

Below is a Yaml configuration file for a pod, that includes a postStart section:


Our postStart hook above, creates a file in the "/tmp" directory.

We could use the postStart hooks for example to test if a pod fulfills certain criteria - network connection, connection to a database, ... -before allowing it to start.

We create our pod using the below command:


We could log inside our pod, using the below command:


Then we could verify if our file has been created using the below command:


Brando Sabatini and Ikbal C ©. Powered by Blogger.