container environment
container information
todo
cluster information
- service environment(和docker注入环境的变量语法一致)
- FOO_SERVICE_HOST=<the host the service is running on>
- FOO_SERVICE_PORT=<the port the service is running on>
Container Hooks
提供信息给container管理生命周期的事件给container,相当于容器的event handler, 尽量保持轻量
PostStart
容器创建被发送,通知容器已经被创建,asynchronous execute, 不保证容器在运行ENTRYPOINT前运行。
PreStop
- 容器被terminaled时发送,必须在容器被删除前执行完毕,synchronous execute ,容器才能删除。
- 具体过程:https://kubernetes.io/docs/user-guide/pods/#termination-of-pods
Hook delivery guarantees
- at least once: hook handler可能被调用两次(in some cases if Kubelet restart), 需要hook implementer注意发送两次的情况
hook handler implementions
exec
在容器的环境内执行指定的命令
http
执行http请求
查看hook事件
kubectl describe pod <pod_name>








网友评论