摘要:記錄一個簡單的的使用創建探針具體的文件如下創建該查看當前的狀態測試將容器內的刪除掉登陸容器使用命令登陸容器可以看到,當我們把移走后,這個容器立馬就退出了。
記錄一個簡單的livenessProb的使用
創建livenessProbe探針具體的liveness-httpget.yaml文件如下:
</>復制代碼
apiVersion: v1
kind: Pod
metadata:
name: liveness-httpget-pod
namespace: default
spec:
containers:
- name: liveness-exec-container
image: ikubernetes/myapp:v1
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 80
livenessProbe:
httpGet:
port: http
path: /index.html
initialDelaySeconds: 1
periodSeconds: 3
[root@master manifests]# cat liveness-httpget.yaml
apiVersion: v1
kind: Pod
metadata:
name: liveness-httpget-pod
namespace: default
spec:
containers:
- name: liveness-exec-container
image: ikubernetes/myapp:v1
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 80
livenessProbe:
httpGet:
port: http
path: /index.html
initialDelaySeconds: 1
periodSeconds: 3
創建該pod
</>復制代碼
[root@master manifests]# kubectl create -f liveness-httpget.yaml
pod/liveness-httpget-pod created
查看當前pod的狀態
</>復制代碼
[root@master manifests]# kubectl describe pod liveness-httpget-pod
Name: liveness-httpget-pod
Namespace: default
Priority: 0
PriorityClassName:
Node: node02/192.168.18.130
Start Time: Fri, 17 Aug 2018 18:24:26 +0800
Labels:
Annotations:
Status: Running
IP: 10.244.2.40
Containers:
liveness-exec-container:
Container ID: docker://b00bc09eac7c4dcadb482dd9795a9f7e6d9b68ca63e75384da18feb0ef7bdc6d
Image: ikubernetes/myapp:v1
Image ID: docker-pullable://ikubernetes/myapp@sha256:9c3dc30b5219788b2b8a4b065f548b922a34479577befb54b03330999d30d513
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Fri, 17 Aug 2018 18:24:27 +0800
Ready: True
Restart Count: 0
Liveness: http-get http://:http/index.html delay=1s timeout=1s period=3s #success=1 #failure=3
Environment:
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-qcfxf (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
default-token-qcfxf:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-qcfxf
Optional: false
QoS Class: BestEffort
Node-Selectors:
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Pulled 37s kubelet, node02 Container image "ikubernetes/myapp:v1" already present on machine
Normal Created 37s kubelet, node02 Created container
Normal Started 37s kubelet, node02 Started container
Normal Scheduled 32s default-scheduler Successfully assigned default/liveness-httpget-pod to node02
測試將容器內的index.html刪除掉
登陸容器
使用命令 kubectl exec liveness-httpget-pod -c liveness-exec-container -it -- /bin/sh 登陸容器
</>復制代碼
[root@master manifests]# kubectl exec liveness-httpget-pod -c liveness-exec-container -it -- /bin/sh
/ # ls
bin dev etc home lib media mnt proc root run sbin srv sys tmp usr var
/ # mv /usr/share/nginx/html/index.html index.html
/ # command terminated with exit code 137
可以看到,當我們把index.html移走后,這個容器立馬就退出了。
此時,查看pod的信息
</>復制代碼
[root@master manifests]# kubectl describe pod liveness-httpget-pod
Name: liveness-httpget-pod
Namespace: default
Priority: 0
PriorityClassName:
Node: node02/192.168.18.130
Start Time: Fri, 17 Aug 2018 18:24:26 +0800
Labels:
Annotations:
Status: Running
IP: 10.244.2.40
Containers:
liveness-exec-container:
Container ID: docker://ac663b9e29c2cbc9c1d0283f1609914be69964149247945266ddcc8b33dde12f
Image: ikubernetes/myapp:v1
Image ID: docker-pullable://ikubernetes/myapp@sha256:9c3dc30b5219788b2b8a4b065f548b922a34479577befb54b03330999d30d513
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Fri, 17 Aug 2018 18:48:07 +0800
Last State: Terminated
Reason: Completed
Exit Code: 0
Started: Fri, 17 Aug 2018 18:24:27 +0800
Finished: Fri, 17 Aug 2018 18:48:06 +0800
Ready: True
Restart Count: 1
Liveness: http-get http://:http/index.html delay=1s timeout=1s period=3s #success=1 #failure=3
Environment:
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-qcfxf (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
default-token-qcfxf:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-qcfxf
Optional: false
QoS Class: BestEffort
Node-Selectors:
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 24m default-scheduler Successfully assigned default/liveness-httpget-pod to node02
Warning Unhealthy 1m (x3 over 1m) kubelet, node02 Liveness probe failed: HTTP probe failed with statuscode: 404
Normal Pulled 1m (x2 over 24m) kubelet, node02 Container image "ikubernetes/myapp:v1" already present on machine
Normal Created 1m (x2 over 24m) kubelet, node02 Created container
Normal Started 1m (x2 over 24m) kubelet, node02 Started container
Normal Killing 1m kubelet, node02 Killing container with id docker://liveness-exec-container:Container failed liveness probe.. Container will be killed and recreated.
看輸出,容器由于健康檢查未通過,pod會被殺掉,并重新創建
</>復制代碼
[root@master manifests]# kubectl get pods
NAME READY STATUS RESTARTS AGE
liveness-httpget-pod 1/1 Running 1 33m
restarts 為 1
重新登陸容器查看重新登陸容器,發現index.html又出現了,證明容器是被重拉了。
</>復制代碼
[root@master manifests]# kubectl exec liveness-httpget-pod -c liveness-exec-container -it -- /bin/sh
/ # cat /usr/share/nginx/html/index.html
Hello MyApp | Version: v1 | Pod Name
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/32699.html
摘要:配置配置使用概率抽樣。采樣率定義了對跟蹤跨度進行采樣的概率,其值可以介于和含之間。例如,以下配置對象將采樣率更改為即每個跨度都被采樣,并使用協議將跟蹤發送到位于的服務器文件路徑注將采樣率更改為會完全禁用跟蹤。目錄手把手教你學Dapr - 1. .Net開發者的大時代手把手教你學Dapr - 2. 必須知道的概念手把手教你學Dapr - 3. 使用Dapr運行第一個.Net程序手把手教你學Da...
摘要:常用命令服務啟動滾動升級概念集群分布式存儲保存了整個集群的狀態控制節點控制節點負責整個集群的管理,例如容器調度資源狀態維護自動擴展滾動更新等服務節點服務節點是真正運行容器 1.常用命令 服務啟動 [root@k8s-master ~]# systemctl start etcd [root@k8s-master ~]# systemctl start docker [root@k8s-...
摘要:在本文中,我們將討論,一種本地健康檢查應用程序的方法。標準的健康檢查工具,可以輕松查詢健康協議。選擇二進制版本并將其下載到中在你的中指定容器的。服務器健康檢查的代碼實現,主要部分如下完整代碼,請查看倉庫。 前言 GRPC正在成為云原生微服務之間通信的通用語言。如果您今天要將gRPC應用程序部署到Kubernetes,您可能想知道配置運行狀況檢查的最佳方法。在本文中,我們將討論grpc-...
摘要:在本文中,我們將討論,一種本地健康檢查應用程序的方法。標準的健康檢查工具,可以輕松查詢健康協議。選擇二進制版本并將其下載到中在你的中指定容器的。服務器健康檢查的代碼實現,主要部分如下完整代碼,請查看倉庫。 前言 GRPC正在成為云原生微服務之間通信的通用語言。如果您今天要將gRPC應用程序部署到Kubernetes,您可能想知道配置運行狀況檢查的最佳方法。在本文中,我們將討論grpc-...
摘要:在本文中,我們將討論,一種本地健康檢查應用程序的方法。標準的健康檢查工具,可以輕松查詢健康協議。選擇二進制版本并將其下載到中在你的中指定容器的。服務器健康檢查的代碼實現,主要部分如下完整代碼,請查看倉庫。 前言 GRPC正在成為云原生微服務之間通信的通用語言。如果您今天要將gRPC應用程序部署到Kubernetes,您可能想知道配置運行狀況檢查的最佳方法。在本文中,我們將討論grpc-...
閱讀 2433·2021-11-18 10:02
閱讀 691·2021-10-08 10:04
閱讀 2261·2021-09-03 10:51
閱讀 3548·2019-08-30 15:44
閱讀 2804·2019-08-29 14:09
閱讀 2470·2019-08-29 12:21
閱讀 2068·2019-08-26 13:45
閱讀 1808·2019-08-26 13:25