Kubernetes provides a clean abstraction called pods for just this use case. It hides the complexity of Docker flags and the need to babysit the containers, shared volumes, and the like. It also hides differences between container runtimes
In Kubernetes, the pause container serves as the “parent container” for all of the containers in your pod. The pause container has two core responsibilities. First, it serves as the basis of Linux namespace sharing in the pod. And second, with PID (process ID) namespace sharing enabled, it serves as PID 1 for each pod and reaps zombie processes.
1 | docker run -d --name pause -p 8080:80 gcr.io/google_containers/pause-amd64:3.0 |
Zombie processes are processes that have stopped running but their process table entry still exists because the parent process hasn’t retrieved it via the wait
syscall. Technically each process that terminates is a zombie for a very short period of time but they could live for longer.
Longer lived zombie processes occur when parent processes don’t call the wait
syscall after the child process has finished
但并不是所有的container部分都可以被指定为PID为1的角色
1 |
|
If PID namespace sharing is not enabled then each container in a Kubernetes pod will have its own PID 1 and each one will need to reap zombie processes itself.