kubernetes - Kubernetes - 准备探测不适用于部署
问题描述
有人可以告诉我部署的 yaml 文件有什么问题吗?当我删除就绪探测时,我可以看到我的部署kubectl get deployments
可用。但是使用就绪探测,它仍然不可用,如下所示。
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
neg-demo-app 1 1 1 0 2m33s
下面是我的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
解决方案
我认为你已经添加了
minReadySeconds: 60 # Number of seconds to wait after a Pod is created and its status is Ready
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.
所以 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.
请尝试添加initialDelaySeconds
in rediness 探针和 liveness 探针,否则尝试删除minReadySeconds
.
推荐阅读
- python - 在Python中动态计算不包括假期日历的工作日数
- java - 使用 Java 从 csv 批量插入到 Oracle DB 中的表
- javascript - 在 GraphicsLayer 中为图形图标添加标签
- c++ - 如何摆脱导入的 make 项目中的 Eclipse 索引器“Type std::... could not be resolved”错误
- python - 如何更新 dockerfile 中的 python 字典?
- lwip - lwIP TCP keepalive 数据包在电缆断开期间不服从设置
- google-analytics - 哪些用户查看了 Google Analytics 中的特定页面
- ios - SWIFT 中的 WhatsApp 与 WhatsApp 业务
- c++ - 在类中声明一个自动 lambda 函数
- postgresql - 如何使用'?在@Query 中?如何在 spring-boot 中使用 postgres 的 Jsonb?