and nothing more. It also offers the same handler types and guarantees as the  post Start  hook we covered previously. In this chapter, so far we have focused on the hooks that allow executing commands when a container lifecycle event occurs. But another mechanism that is not at the container level but at a Pod level allows executing initialization instructions. We describe in Chapter 14,  Init Container , in depth, but here we describe it briefly to compare it with lifecycle hooks. Unlike regular application containers, init containers run sequentially, run until completion, and run before any of the application contain‐ ers in a Pod start up. These guarantees allow using init containers for Pod-level initi‐ alization tasks. Both lifecycle hooks and init containers operate at a different granularity (at container level and Pod-level, respectively) and could be used inter‐ changeably in some instances, or complement each other in other cases. Table 5-1 summarizes the main differences between the two. There are no strict rules about which mechanism to use except when you require a specific timing guarantee. We could skip lifecycle hooks and init containers entirely and use a bash script to perform specific actions as part of a container’s startup or shutdown commands. That is possible, but it would tightly couple the container with the script and turn it into a maintenance nightmare. We could also use Kubernetes lifecycle hooks to perform some actions as described in this chapter. Alternatively, we could go even further and run containers that perform individual actions using init containers. In this sequence, the options require more effort increasingly, but at the same time offer stronger guarantees and enable reuse. Understanding the stages and available hooks of containers and Pod lifecycles is cru‐ cial for creating applications that benefit from being managed by Kubernetes. Table 5-1. Lifecycle Hooks and Init Containers Aspect Lifecycle hooks Init Containers Activates on Container lifecycle phases Pod lifecycle phases Startup phase action A  postStart  command A list of  initContainers  to execute Shutdown phase action A  preStop  command No equivalent feature exists yet Timing guarantees A  postStart  command is executed at the same time as the container’s  ENTRYPOINT All init containers must be completed successfully before any application container can start Use cases Perform noncritical startup/shutdown cleanups specific to a container Perform workflow-like sequential operations using containers; reuse containers for task executions Other Lifecycle Controls Solution  |  45