我用Jenkins和Kubernetes来执行这个动作。
因为我的loadBalancer需要一个健康的吊舱,所以我不得不将livenessProbe添加到我的吊舱中。
我的吊舱配置:
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对如何解决这个问题有什么建议吗?
我已经阅读了这个关于活性的文档,并从那里获取了它的配置。
发布于 2018-10-29 15:42:24
从您所指的链接中可以看出。这个例子是为了帮助你了解活性探针的工作原理。下面是这个链接中的示例
之后,他们故意删除/tmp/健康文件
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秒后,它将删除该文件,而活动探测无法找到/tmp/healthy文件,并重新启动容器。这一过程将继续进行,每隔30秒就会有活性探针无法通过健康检查。
如果您只添加
活性探针应能正常工作。
https://stackoverflow.com/questions/53048351
复制相似问题