我在我的 k8s pod 中使用就緒探測功能。為此,探針檢查檔案 /tmp/healthy 是否存在。如果不是,則探測標記吊艙未就緒。我觀察到如果我再次創建檔案 /tmp/healthy,pod 不會回到 READY 狀態。這是否意味著,在 pod 生命周期中,只有 READY--> UN-READY 的路徑,反之則不然?
/home/ravi/for_others/ric/stub>kubectl describe pod -n myns deployment-eterm
Name: deployment-eterm
Namespace: myns
Priority: 0
Status: Running
IP: 192.168.252.87
IPs:
IP: 192.168.252.87
Controlled By: ReplicaSet/deployment-myns-eterm-micro-6b896556c8
Containers:
Liveness: exec [/bin/sh -c /tmp/liveliness-status-collector.sh] delay=60s timeout=1s period=2s #success=1 #failure=5
Readiness: exec [/bin/sh -c cat /tmp/healthy] delay=60s timeout=1s period=10s #success=1 #failure=1
Environment Variables from:
configmap-myns-eterm-env-micro ConfigMap Optional: false
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-57jpz (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 9m11s default-scheduler Successfully assigned myns/deployment-eterm to mnode
Normal Pulled 9m10s kubelet, mnode Container image "porics.microlab.com:5000/eterm:latest" already present on machine
Normal Created 9m10s kubelet, mnode Created container container-myns-eterm
Normal Started 9m10s kubelet, mnode Started container container-myns-eterm
Normal Pulled 9m10s kubelet, mnode Container image "porics.microlab.com:5000/config-proxy:latest" already present on machine
Normal Created 9m10s kubelet, mnode Created container container-myns-configproxy
Normal Started 9m10s kubelet, mnode Started container container-myns-configproxy
Warning Unhealthy 3s (x3 over 23s) kubelet, mnode Readiness probe failed: cat: /tmp/healthy: No such file or directory
/home/ravi/for_others/ric/stub>
uj5u.com熱心網友回復:
以下陳述不正確:
這是否意味著,在 pod 生命周期中,只有一條 READY--> UN-READY 路徑,反之則不然?
您可以運行以下實驗來查看 pod 轉換:
使用以下清單檔案創建一個 pod:
apiVersion: v1
kind: Pod
metadata:
labels:
test: readiness
name: readiness-test
spec:
nodeName: kube-master
containers:
- name: liveness
image: bash
command: ['bash','-c', 'while true;do echo "$(date): creating /tmp/healthy"; touch /tmp/healthy; sleep 10; echo "$(date): deleting /tmp/healthy";rm /tmp/healthy ;sleep 10;done']
readinessProbe:
exec:
command:
- cat
- /tmp/healthy
initialDelaySeconds: 5
periodSeconds: 2
上述清單將導致 Pod 每 10 秒轉換一次就緒/未就緒狀態。
kubectl get pod -w
NAME READY STATUS RESTARTS AGE
readiness-test 0/1 Running 0 79s
readiness-test 1/1 Running 0 83s
readiness-test 0/1 Running 0 97s
readiness-test 1/1 Running 0 103s
readiness-test 0/1 Running 0 117s
readiness-test 1/1 Running 0 2m3s
readiness-test 0/1 Running 0 2m17s
readiness-test 1/1 Running 0 2m23s
readiness-test 0/1 Running 0 2m37s
readiness-test 1/1 Running 0 2m43s
readiness-test 0/1 Running 0 2m57s
readiness-test 1/1 Running 0 3m3s
readiness-test 0/1 Running 0 3m17s
readiness-test 1/1 Running 0 3m23s
readiness-test 0/1 Running 0 3m37s
readiness-test 1/1 Running 0 3m43s
readiness-test 0/1 Running 0 3m57s
readiness-test 1/1 Running 0 4m3s
您可以看到準備狀態正在發生變化:
while true; do k get pod readiness-test -o jsonpath='{.status.containerStatuses[*].ready}{"\n"}';sleep 2 ;done
true
true
true
true
true
true
false
false
true
true
true
true
true
true
false
false
true
true
true
true
true
true
false
false
true
true
true
true
true
false
false
false
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/478967.html
上一篇:選擇查詢中的CASTtoTIME需要很長時間才能執行
下一篇:從另一個ec2實體訪問控制平面
