摘要:記錄一個(gè)簡(jiǎn)單的的使用創(chuàng)建探針具體的文件如下創(chuàng)建該查看當(dāng)前的狀態(tài)測(cè)試將容器內(nèi)的刪除掉登陸容器使用命令登陸容器可以看到,當(dāng)我們把移走后,這個(gè)容器立馬就退出了。
記錄一個(gè)簡(jiǎn)單的livenessProb的使用
創(chuàng)建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
創(chuàng)建該pod
[root@master manifests]# kubectl create -f liveness-httpget.yaml pod/liveness-httpget-pod created
查看當(dāng)前pod的狀態(tài)
[root@master manifests]# kubectl describe pod liveness-httpget-pod Name: liveness-httpget-pod Namespace: default Priority: 0 PriorityClassName:測(cè)試將容器內(nèi)的index.html刪除掉 登陸容器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
使用命令 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
可以看到,當(dāng)我們把index.html移走后,這個(gè)容器立馬就退出了。
此時(shí),查看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會(huì)被殺掉,并重新創(chuàng)建
[root@master manifests]# kubectl get pods NAME READY STATUS RESTARTS AGE liveness-httpget-pod 1/1 Running 1 33m
restarts 為 1
重新登陸容器查看重新登陸容器,發(fā)現(xiàn)index.html又出現(xiàn)了,證明容器是被重拉了。
[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
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/32699.html
摘要:配置配置使用概率抽樣。采樣率定義了對(duì)跟蹤跨度進(jìn)行采樣的概率,其值可以介于和含之間。例如,以下配置對(duì)象將采樣率更改為即每個(gè)跨度都被采樣,并使用協(xié)議將跟蹤發(fā)送到位于的服務(wù)器文件路徑注將采樣率更改為會(huì)完全禁用跟蹤。目錄手把手教你學(xué)Dapr - 1. .Net開發(fā)者的大時(shí)代手把手教你學(xué)Dapr - 2. 必須知道的概念手把手教你學(xué)Dapr - 3. 使用Dapr運(yùn)行第一個(gè).Net程序手把手教你學(xué)Da...
摘要:常用命令服務(wù)啟動(dòng)滾動(dòng)升級(jí)概念集群分布式存儲(chǔ)保存了整個(gè)集群的狀態(tài)控制節(jié)點(diǎn)控制節(jié)點(diǎn)負(fù)責(zé)整個(gè)集群的管理,例如容器調(diào)度資源狀態(tài)維護(hù)自動(dòng)擴(kuò)展?jié)L動(dòng)更新等服務(wù)節(jié)點(diǎn)服務(wù)節(jié)點(diǎn)是真正運(yùn)行容器 1.常用命令 服務(wù)啟動(dòng) [root@k8s-master ~]# systemctl start etcd [root@k8s-master ~]# systemctl start docker [root@k8s-...
摘要:在本文中,我們將討論,一種本地健康檢查應(yīng)用程序的方法。標(biāo)準(zhǔn)的健康檢查工具,可以輕松查詢健康協(xié)議。選擇二進(jìn)制版本并將其下載到中在你的中指定容器的。服務(wù)器健康檢查的代碼實(shí)現(xiàn),主要部分如下完整代碼,請(qǐng)查看倉(cāng)庫。 前言 GRPC正在成為云原生微服務(wù)之間通信的通用語言。如果您今天要將gRPC應(yīng)用程序部署到Kubernetes,您可能想知道配置運(yùn)行狀況檢查的最佳方法。在本文中,我們將討論grpc-...
摘要:在本文中,我們將討論,一種本地健康檢查應(yīng)用程序的方法。標(biāo)準(zhǔn)的健康檢查工具,可以輕松查詢健康協(xié)議。選擇二進(jìn)制版本并將其下載到中在你的中指定容器的。服務(wù)器健康檢查的代碼實(shí)現(xiàn),主要部分如下完整代碼,請(qǐng)查看倉(cāng)庫。 前言 GRPC正在成為云原生微服務(wù)之間通信的通用語言。如果您今天要將gRPC應(yīng)用程序部署到Kubernetes,您可能想知道配置運(yùn)行狀況檢查的最佳方法。在本文中,我們將討論grpc-...
摘要:在本文中,我們將討論,一種本地健康檢查應(yīng)用程序的方法。標(biāo)準(zhǔn)的健康檢查工具,可以輕松查詢健康協(xié)議。選擇二進(jìn)制版本并將其下載到中在你的中指定容器的。服務(wù)器健康檢查的代碼實(shí)現(xiàn),主要部分如下完整代碼,請(qǐng)查看倉(cāng)庫。 前言 GRPC正在成為云原生微服務(wù)之間通信的通用語言。如果您今天要將gRPC應(yīng)用程序部署到Kubernetes,您可能想知道配置運(yùn)行狀況檢查的最佳方法。在本文中,我們將討論grpc-...
閱讀 2434·2021-11-18 10:02
閱讀 696·2021-10-08 10:04
閱讀 2271·2021-09-03 10:51
閱讀 3552·2019-08-30 15:44
閱讀 2807·2019-08-29 14:09
閱讀 2474·2019-08-29 12:21
閱讀 2071·2019-08-26 13:45
閱讀 1813·2019-08-26 13:25