GCP Kubernetes在System.exit(1)上的行为

时间:2019-09-13 09:18:01

标签: kubernetes google-cloud-platform

时,Spring Boot应用程序在GCP Kubernetes上的默认行为是什么?
  

System.exit(1)

被称为? kubernetes会重新创建容器吗? 如果没有-如果我的应用程序崩溃,我该如何强制娱乐?

-亚历克斯

1 个答案:

答案 0 :(得分:1)

在应用程序kubernetes的退出代码上,将重新启动POD内的容器,并且pod状态将在Ready列中变为。

如果要优雅地终止吊舱,可以看一下:https://dzone.com/articles/gracefully-shutting-down-java-in-containers

Terminated: Indicates that the container completed its execution and has stopped running. A container enters into this when it has successfully completed execution or when it has failed for some reason. Regardless, a reason and exit code is displayed, as well as the container’s start and finish time. Before a container enters into Terminated, preStop hook (if any) is executed.

...
      State:          Terminated
        Reason:       Completed
        Exit Code:    0
        Started:      Wed, 30 Jan 2019 11:45:26 +0530
        Finished:     Wed, 30 Jan 2019 11:45:26 +0530
    ...

请查看kubernetes官方文档:https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/