Liveness/Readiness 探测器如何与 pod 通信?
How does a Liveness/Readiness probe communicate with a pod?
我是 k8s 的新手,所以如果问题没有意义或 incorrect/stupid,我深表歉意。
我为我的 pod 定义配置了一个活动探测器,它刚刚命中一个健康 API 并检查它的响应状态以测试 pod 的活动。
我的问题是,虽然我了解 liveness/readiness 探测器的用途...它们到底是什么?它们只是另一种类型的 pods,它们被启动以尝试通过配置的 API 与我们的 pod 通信吗?或者它们是某种在 pod 本身内部运行并尝试 API 调用的轻量级进程?
此外,探测器如何与 pod 通信?我们是否需要为 pod 配置服务以便探测器能够访问 API 或者它是一个不需要额外配置的内部进程?
对于网络探测,它们是 运行 来自 pod 运行ning 节点上的 kubelet。 Exec 探测 运行 通过与 kubectl exec.
相同的机制
简短回答: kubelet 处理此检查以确保您的服务是 运行,如果不是,它将被另一个容器替换。 Kubelet 运行在你集群的每个节点上,你不需要做任何额外的配置。
您不需要配置服务帐户来让探测工作,它是由 kubernetes 处理的内部进程。
来自 Kubernetes documentation:
A Probe is a diagnostic performed periodically by the kubelet on a Container. To perform a diagnostic, the kubelet calls a Handler implemented by the Container. There are three types of handlers:
ExecAction: Executes a specified command inside the Container. The diagnostic is considered successful if the command exits with a status code of 0.
TCPSocketAction: Performs a TCP check against the Container’s IP address on a specified port. The diagnostic is considered successful if the port is open.
HTTPGetAction: Performs an HTTP Get request against the Container’s IP address on a specified port and path. The diagnostic is considered successful if the response has a status code greater than or equal to 200 and less than 400.
Each probe has one of three results:
- Success: The Container passed the diagnostic.
- Failure: The Container failed the diagnostic.
- Unknown: The diagnostic failed, so no action should be taken.
The kubelet can optionally perform and react to three kinds of probes on running Containers:
livenessProbe
: Indicates whether the Container is running. If the liveness probe fails, the kubelet kills the Container, and the Container is subjected to its restart policy. If a Container does not provide a liveness probe, the default state is Success
.
readinessProbe
: Indicates whether the Container is ready to service requests. If the readiness probe fails, the endpoints controller removes the Pod’s IP address from the endpoints of all Services that match the Pod. The default state of readiness before the initial delay is Failure
. If a Container does not provide a readiness probe, the default state is Success
.
startupProbe
: Indicates whether the application within the Container is started. All other probes are disabled if a startup probe is provided, until it succeeds. If the startup probe fails, the kubelet kills the Container, and the Container is subjected to its restart policy. If a Container does not provide a startup probe, the default state is Success
.
我是 k8s 的新手,所以如果问题没有意义或 incorrect/stupid,我深表歉意。
我为我的 pod 定义配置了一个活动探测器,它刚刚命中一个健康 API 并检查它的响应状态以测试 pod 的活动。
我的问题是,虽然我了解 liveness/readiness 探测器的用途...它们到底是什么?它们只是另一种类型的 pods,它们被启动以尝试通过配置的 API 与我们的 pod 通信吗?或者它们是某种在 pod 本身内部运行并尝试 API 调用的轻量级进程?
此外,探测器如何与 pod 通信?我们是否需要为 pod 配置服务以便探测器能够访问 API 或者它是一个不需要额外配置的内部进程?
对于网络探测,它们是 运行 来自 pod 运行ning 节点上的 kubelet。 Exec 探测 运行 通过与 kubectl exec.
相同的机制简短回答: kubelet 处理此检查以确保您的服务是 运行,如果不是,它将被另一个容器替换。 Kubelet 运行在你集群的每个节点上,你不需要做任何额外的配置。
您不需要配置服务帐户来让探测工作,它是由 kubernetes 处理的内部进程。
来自 Kubernetes documentation:
A Probe is a diagnostic performed periodically by the kubelet on a Container. To perform a diagnostic, the kubelet calls a Handler implemented by the Container. There are three types of handlers:
ExecAction: Executes a specified command inside the Container. The diagnostic is considered successful if the command exits with a status code of 0.
TCPSocketAction: Performs a TCP check against the Container’s IP address on a specified port. The diagnostic is considered successful if the port is open.
HTTPGetAction: Performs an HTTP Get request against the Container’s IP address on a specified port and path. The diagnostic is considered successful if the response has a status code greater than or equal to 200 and less than 400.
Each probe has one of three results:
- Success: The Container passed the diagnostic.
- Failure: The Container failed the diagnostic.
- Unknown: The diagnostic failed, so no action should be taken.
The kubelet can optionally perform and react to three kinds of probes on running Containers:
livenessProbe
: Indicates whether the Container is running. If the liveness probe fails, the kubelet kills the Container, and the Container is subjected to its restart policy. If a Container does not provide a liveness probe, the default state isSuccess
.
readinessProbe
: Indicates whether the Container is ready to service requests. If the readiness probe fails, the endpoints controller removes the Pod’s IP address from the endpoints of all Services that match the Pod. The default state of readiness before the initial delay isFailure
. If a Container does not provide a readiness probe, the default state isSuccess
.
startupProbe
: Indicates whether the application within the Container is started. All other probes are disabled if a startup probe is provided, until it succeeds. If the startup probe fails, the kubelet kills the Container, and the Container is subjected to its restart policy. If a Container does not provide a startup probe, the default state isSuccess
.