Kubernetes - 就绪探针不适用于部署

Muh*_*han 1 google-compute-engine kubernetes readinessprobe

有人可以告诉我用于部署的 yaml 文件有什么问题吗?当我删除就绪探针时,我可以看到我的部署kubectl get deployments可用。但使用就绪探针后,它仍然不可用,如下所示。

NAME           DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
neg-demo-app   1         1         1            0           2m33s
Run Code Online (Sandbox Code Playgroud)

下面是我的yaml文件

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    run: neg-demo-app # Label for the Deployment
  name: neg-demo-app # Name of Deployment
spec: # Deployment's specification
  minReadySeconds: 60 # Number of seconds to wait after a Pod is created and its status is Ready
  selector:
    matchLabels:
      run: neg-demo-app
  template: # Pod template
    metadata:
      labels:
        run: neg-demo-app # Labels Pods from this Deployment
    spec: # Pod specification; each Pod created by this Deployment has this specification
      containers:
      - image: container_name  # Application to run in Deployment's Pods
        name: hostname # Container name
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8080
            scheme: HTTP
        readinessProbe:
          httpGet:
            path: /healthz
            port: 8080
            scheme: HTTP
      terminationGracePeriodSeconds: 60 # Number of seconds to wait for connections to terminate before shutting down Pods
Run Code Online (Sandbox Code Playgroud)

Har*_*var 5

我认为你添加了

minReadySeconds: 60 # Number of seconds to wait after a Pod is created and its status is Ready
Run Code Online (Sandbox Code Playgroud)

minReadySeconds 是一个可选字段,它指定新创建的 Pod 在其任何容器不崩溃的情况下应准备就绪的最小秒数,以便将其视为可用。默认值为 0(Pod 一旦准备好就被视为可用)。

So your newly created app pod have to be ready for minReadySeconds 60 seconds to be considered as available.


initialDelaySeconds: Number of seconds after the container has started before liveness or readiness probes are initiated.
Run Code Online (Sandbox Code Playgroud)

因此,initialDelaySeconds 出现在 minReadySeconds 之前。

container in the pod has started at 5 seconds. Readiness probe will be initiated at 5+initialDelaySeconds seconds. Assume Pod become ready at 7 seconds(7 > 5+initialDelaySeconds). So this pod will be available after 7+minReadySeconds seconds.
Run Code Online (Sandbox Code Playgroud)

请尝试添加initialDelaySecondsin rediness 探针和 liveness 探针,否则尝试删除minReadySeconds.