0

我正在使用 Spring Boot 应用程序。我已经使用 REST API 端点包含了 http liveness probe config。因此,只要 REST API 无法访问,Kubernetes 就会重新启动 pod。

问题是,我需要确定是否有任何方法可以区分由 Liveness Probe 触发的 Pod 重启活动与部署团队完成的手动重启。

每当重新启动 Pod 时,Kubernetes 是否会在 Spring Boot 日志中包含任何类型的日志消息?

4

1 回答 1

2

如果您描述了 pod,您应该Liveness probe failed会在活性探测失败时看到一条消息。

kubectl describe pod liveness-exec

FirstSeen LastSeen    Count   From            SubobjectPath           Type        Reason      Message
--------- --------    -----   ----            -------------           --------    ------      -------
37s       37s     1   {default-scheduler }                    Normal      Scheduled   Successfully assigned liveness-exec to worker0
36s       36s     1   {kubelet worker0}   spec.containers{liveness}   Normal      Pulling     pulling image "k8s.gcr.io/busybox"
36s       36s     1   {kubelet worker0}   spec.containers{liveness}   Normal      Pulled      Successfully pulled image "k8s.gcr.io/busybox"
36s       36s     1   {kubelet worker0}   spec.containers{liveness}   Normal      Created     Created container with docker id 86849c15382e; Security:[seccomp=unconfined]
36s       36s     1   {kubelet worker0}   spec.containers{liveness}   Normal      Started     Started container with docker id 86849c15382e
2s        2s      1   {kubelet worker0}   spec.containers{liveness}   Warning     Unhealthy   Liveness probe failed: cat: can't open '/tmp/healthy': No such file or directory
于 2021-02-19T08:54:53.383 回答