|
| 1 | +--- |
| 2 | +title: 存活、就绪和启动探针 |
| 3 | +content_type: concept |
| 4 | +weight: 40 |
| 5 | +--- |
| 6 | +<!-- |
| 7 | +title: Liveness, Readiness, and Startup Probes |
| 8 | +content_type: concept |
| 9 | +weight: 40 |
| 10 | +--> |
| 11 | + |
| 12 | +<!-- overview --> |
| 13 | + |
| 14 | +<!-- |
| 15 | +Kubernetes has various types of probes: |
| 16 | +
|
| 17 | +- [Liveness probe](#liveness-probe) |
| 18 | +- [Readiness probe](#readiness-probe) |
| 19 | +- [Startup probe](#startup-probe) |
| 20 | +--> |
| 21 | +Kubernetes 提供了多种探针: |
| 22 | + |
| 23 | +- [存活探针](#liveness-probe) |
| 24 | +- [就绪探针](#readiness-probe) |
| 25 | +- [启动探针](#startup-probe) |
| 26 | + |
| 27 | +<!-- body --> |
| 28 | + |
| 29 | +<!-- |
| 30 | +## Liveness probe |
| 31 | +
|
| 32 | +Liveness probes determine when to restart a container. For example, liveness probes could catch a deadlock, when an application is running, but unable to make progress. |
| 33 | +--> |
| 34 | +## 存活探针 {#liveness-probe} |
| 35 | + |
| 36 | +存活探针决定何时重启容器。 |
| 37 | +例如,当应用在运行但无法取得进展时,存活探针可以捕获这类死锁。 |
| 38 | + |
| 39 | +<!-- |
| 40 | +If a container fails its liveness probe repeatedly, the kubelet restarts the container. |
| 41 | +--> |
| 42 | +如果一个容器的存活探针失败多次,kubelet 将重启该容器。 |
| 43 | + |
| 44 | +<!-- |
| 45 | +Liveness probes do not wait for readiness probes to succeed. If you want to wait before |
| 46 | +executing a liveness probe you can either define `initialDelaySeconds`, or use a |
| 47 | +[startup probe](#startup-probe). |
| 48 | +--> |
| 49 | +存活探针不会等待就绪探针成功。 |
| 50 | +如果你想在执行存活探针前等待,你可以定义 `initialDelaySeconds`,或者使用[启动探针](#startup-probe)。 |
| 51 | + |
| 52 | +<!-- |
| 53 | +## Readiness probe |
| 54 | +
|
| 55 | +Readiness probes determine when a container is ready to start accepting traffic. This is useful when waiting for an application to perform time-consuming initial tasks, such as establishing network connections, loading files, and warming caches. |
| 56 | +--> |
| 57 | +## 就绪探针 {#readiness-probe} |
| 58 | + |
| 59 | +就绪探针决定何时容器准备好开始接受流量。 |
| 60 | +这种探针在等待应用执行耗时的初始任务时非常有用,例如建立网络连接、加载文件和预热缓存。 |
| 61 | + |
| 62 | +<!-- |
| 63 | +If the readiness probe returns a failed state, Kubernetes removes the pod from all matching service endpoints. |
| 64 | +
|
| 65 | +Readiness probes runs on the container during its whole lifecycle. |
| 66 | +--> |
| 67 | +如果就绪探针返回的状态为失败,Kubernetes 会将该 Pod 从所有对应服务的端点中移除。 |
| 68 | + |
| 69 | +就绪探针在容器的整个生命期内持续运行。 |
| 70 | + |
| 71 | +<!-- |
| 72 | +## Startup probe |
| 73 | +
|
| 74 | +A startup probe verifies whether the application within a container is started. This can be used to adopt liveness checks on slow starting containers, avoiding them getting killed by the kubelet before they are up and running. |
| 75 | +--> |
| 76 | +## 启动探针 {#startup-probe} |
| 77 | + |
| 78 | +启动探针检查容器内的应用是否已启动。 |
| 79 | +启动探针可以用于对慢启动容器进行存活性检测,避免它们在启动运行之前就被 kubelet 杀掉。 |
| 80 | + |
| 81 | +<!-- |
| 82 | +If such a probe is configured, it disables liveness and readiness checks until it succeeds. |
| 83 | +--> |
| 84 | +如果配置了这类探针,它会禁用存活检测和就绪检测,直到启动探针成功为止。 |
| 85 | + |
| 86 | +<!-- |
| 87 | +This type of probe is only executed at startup, unlike readiness probes, which are run periodically. |
| 88 | +
|
| 89 | +* Read more about the [Configure Liveness, Readiness and Startup Probes](/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes). |
| 90 | +--> |
| 91 | +这类探针仅在启动时执行,不像就绪探针那样周期性地运行。 |
| 92 | + |
| 93 | +* 更多细节参阅[配置存活、就绪和启动探针](/zh-cn/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes)。 |
0 commit comments