Skip to content

Readiness Probe

一句话解释

readiness probe 检查如果容器是 ready 到 handle 请求; 如果它 失败, 容器是 移除从 Service's 端点.

用大白话说

A readiness probe tells Kubernetes whether your container is ready to receive traffic. If the probe fails, Kubernetes removes the container from the Service's endpoint list — no traffic is sent to it, but it is NOT restarted.

这个是different from a liveness probe。 A container might be running (liveness passes) but not ready — for example, it might still be loading a large dataset, warming up caches, or waiting for a database connection. During this time, you do not want to send user requests to it.

Once the readiness probe starts succeeding, Kubernetes adds the container back to the Service's endpoints and starts sending traffic. This is especially useful during rolling updates — new containers do not receive traffic until they are ready.

示例

yaml
apiVersion: v1
kind: Pod
metadata:
  name: my-app
spec:
  containers:
    - name: my-app
      image: my-app:latest
      readinessProbe:
        httpGet:
          path: /ready
          port: 8080
        initialDelaySeconds: 5
        periodSeconds: 10

这个 readiness probe calls /ready 每个 10 seconds. 直到它 返回 200, 否 traffic 是发送到 这个容器.

工作原理

  1. Kubernetes calls the readiness probe at regular intervals.
  2. If the probe succeeds, the container is added to the Service's endpoints.
  3. If the probe fails, the container is removed from endpoints (no traffic).
  4. The container is NOT restarted — it stays running but receives no requests.

常见混淆

  • 容易混淆的对象: Liveness Probe

    关键区别: readiness probe controls traffic routing (移除从 Service 如果不 ready); liveness probe controls restarts (重启如果不 alive).

相关术语

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表