jenkins - Liveness Probe 被计时
问题描述
我正在使用 Jenkins 和 Kubernetes 来执行此操作。
由于我的 loadBalancer 需要一个健康的 pod,我不得不将 livenessProbe 添加到我的 pod 中。
我对 Pod 的配置:
apiVersion: v1
kind: Pod
metadata:
labels:
component: ci
spec:
# Use service account that can deploy to all namespaces
serviceAccountName: default
# Use the persisnte volume
containers:
- name: gcloud
image: gcr.io/cloud-builders/gcloud
command:
- cat
tty: true
- name: kubectl
image: gcr.io/cloud-builders/kubectl
command:
- cat
tty: true
- name: liveness
image: k8s.gcr.io/busybox
args:
- /bin/sh
- -c
- touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600
livenessProbe:
exec:
command:
- cat
- /tmp/healthy
initialDelaySeconds: 5
periodSeconds: 5
发生的问题是当我想部署代码(CD over Jenkins)时,它涉及到
/tmp/健康;
命令,它已超时。
我得到的错误响应如下所示:
java.io.IOException: Failed to execute shell script inside container [kubectl] of pod [wobbl-mobile-label-qcd6x-13mtj]. Timed out waiting for the container to become ready!
当我输入kubectl get events时 ,我得到以下响应:
Liveness probe failed: cat: can't open '/tmp/healthy': No such file or directory
关于如何解决这个问题的任何提示?
我已阅读此文档以了解其活性,并从那里获取了它的配置。
解决方案
从您所指的链接可以看出。该示例旨在帮助您了解活性探针的工作原理。我从这个链接下面的例子
他们故意删除 /tmp/healthy 文件后
apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness
name: liveness-exec
spec:
containers:
- name: liveness
image: k8s.gcr.io/busybox
args:
- /bin/sh
- -c
- touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600
livenessProbe:
exec:
command:
- cat
- /tmp/healthy
initialDelaySeconds: 5
periodSeconds: 5
它的作用是在创建容器时创建 /tmp/healthy 文件。5 秒后,活性探针启动并检查 /tmp/healthy 文件,此时容器确实存在 /tmp/healthy 文件。30 秒后,它会删除文件,并且 liveness 探测无法找到 /tmp/healthy 文件并重新启动容器。此过程将继续进行,并且每 30 秒后,liveness probe 将无法通过健康检查。
如果你只添加
- 触摸/tmp/健康
活性探针应该可以正常工作
推荐阅读
- spring - Spring Boot 应用程序中的“java.lang.IllegalStateException:无法加载驱动程序类”
- ruby-on-rails - RoR:在 office365 中从模板创建 PowerPoint 演示文稿
- jquery - 我想从用户使用 jquery 填写的表单输入中动态更改按钮的值
- tornadofx - 父视图和子视图是否可以在初始化完成之前通过注入/查找相互引用?
- fortran - fortran中依赖于编译器的空指针问题
- c - 绑定到 INADDR_LOOPBACK 时“无法分配请求的地址”,但 INADDR_ANY 有效
- javascript - Rails 5 simple_form 将单选按钮标记为必需,如果未填写则阻止提交表单
- r - 按组格式化输出表
- javascript - 保存内容通过 Rails 中的表单到我的数据库
- c# - Windows 窗体引用和具有冲突导入类型的单例