Pod生命周期和Liveness的区别

今天测试给我反馈了一个pod问题,测试给出的 use case 描述如下: 配置一个nginx的web服务; 在生命周期中选择http协议,端口配置80,路径配置/errorpath; 服务中pod能正常启动; 预期在pod的事件中应该有一个“FailedPostStartHook”错误信息。 测试人员发现,第4点的预期没有达到,pod 正常启动了,却没有 FailedPostStarHook事件出现。 简单分析了一下,我发现是测试人员把pod的lifecycle和 pod的liveness/readiness 诺混淆了,从而写出了错的test case。 Lifecycle handlers 首先回顾下pod lifecycle的作用: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 kubectl explain pod.spec.containers.lifecycle.postStart RESOURCE: postStart <Object> DESCRIPTION: PostStart is called immediately after a container is created. If the handler fails, the container is terminated and restarted according to its restart policy. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/ container-lifecycle-hooks/#container-hooks/ Handler defines a specific action that should be taken 简单翻译下就是说, kubernetes 提供的pod start和exit的 lifecycle hooks 方便开发人员hooked到 ...

September 18, 2018 · datewu