Add initial lifecycle and hooks into kubelet.

We execute the script only when stopping the container explicitly via Kubernetes operations?

And then Docker sends SIGTERM with (unconfigurable) 10 seconds notice? To me, this implies that we don't expect people to run Docker containers in Kubernetes that they also run in other systems. Like it or not, the standard convention across many PaaSes (e.g., AppEngine, Heroku) and process managers (upstart, systemd, etc.) is to send SIGTERM followed by SIGKILL.  Load-balanced services typically start to fail readiness checks upon SIGTERM but continue running until the SIGKILL to ensure that they serve any requests in flight before the load balancer redirects traffic. For an application with bounded wind-down tasks, the way the application communicates completion is by simply exiting when ready. It could use standard mechanisms to report termination status. We probably need to support both mechanisms, so we can maintain consistency with industry convention, as well as with other hooks.

VM-oriented configuration management systems obviously don't have the option to use SIGTERM, so they always use scripts.