一起来学k8s 05.health check

2024-03-14 14:32

本文主要是介绍一起来学k8s 05.health check,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Pod Health Check

Kubernetes集群当中,我们可以通过配置liveness probe(存活探针)和readiness probe(可读性探针)来影响容器的生存周期。

  1. 使用 liveness probe 来确定你的应用程序是否正在运行,通俗点将就是是否还活着。一般来说,如果你的程序一旦崩溃了, Kubernetes 就会立刻知道这个程序已经终止了,然后就会重启这个程序。而我们的 liveness probe 的目的就是来捕获到当前应用程序还没有终止,还没有崩溃,如果出现了这些情况,那么就重启处于该状态下的容器,使应用程序在存在 bug 的情况下依然能够继续运行下去。
  2. 使用 readiness probe 来确定容器是否已经就绪可以接收流量过来了。这个探针通俗点讲就是说是否准备好了,现在可以开始工作了。只有当 Pod 中的容器都处于就绪状态的时候 kubelet 才会认定该 Pod 处于就绪状态,因为一个 Pod 下面可能会有多个容器。当然 Pod 如果处于非就绪状态,那么我们就会将他从我们的工作队列中移除出来,这样我们的流量就不会被路由到这个 Pod 里面来了。

这两个探针的支持两种配置方式:

exec:执行一段命令
http:检测某个http请求
tcpSocket:检查端口

环境

192.168.48.101 master01
192.168.48.201 node01
192.168.48.202 node02

liveness probe

准备模板health-hook.yaml

vim health-pod.yamlapiVersion: v1
kind: Pod
metadata:name: health-podnamespace: defaultlabels:app: myapptype: pod
spec:containers:- name: myappimage: ikubernetes/myapp:v1ports:- name: httpcontainerPort: 80- name: busyboximage: busybox:latestcommand:- "/bin/sh"- "-c"- "mkdir -p /usr/share/nginx/html; echo $(date) >> /usr/share/nginx/html/test.html;sleep 3600"

exec

编写exec-health-hook.yaml

cp health-hook.yaml  exec-health-hook.yaml 
vim exec-health-hook.yaml apiVersion: v1
kind: Pod
metadata:name: exec-health-podnamespace: defaultlabels:app: myapptype: pod
spec:containers:- name: myappimage: ikubernetes/myapp:v1ports:- name: httpcontainerPort: 80- name: busyboximage: busybox:latestcommand:- "/bin/sh"- "-c"- "touch /tmp/health; sleep 30; rm -rf /tmp/healthy; sleep 600"livenessProbe:exec:command: ["cat /tmp/health"]initialDelaySeconds: 5periodSeconds: 5

创建exec-health-hook.yaml

[root@master01 pod_yaml]# kubectl apply -f exec-health-hook.yaml 
pod/exec-health-pod created[root@master01 pod_yaml]# kubectl get pod
NAME                 READY   STATUS    RESTARTS   AGE
demo-pod             2/2     Running   14         6d5h
demo-pod-ssd         1/1     Running   2          4d21h
exec-health-pod      2/2     Running   0          86s
poststart-hook-pod   2/2     Running   1          86m
initialDelaySeconds:第一次执行探针的时候要等待时间
periodSeconds:每隔多久执行一次存活探针

设置initialDelaySeconds表示在第一次执行探针的时候要等待5秒,这样能够确保我们的容器能够有足够的时间启动起来。设置periodSeconds属性表示让kubelet每隔5秒执行一次存活探针,也就是每5秒执行一次上面的cat /tmp/healthy命令,如果命令执行成功了,将返回0,那么kubelet就会认为当前这个容器是存活的并且很监控,如果返回的是非0值,那么kubelet就会把该容器杀掉然后重启它。

探针还可以配置如下几个参数
timeoutSeconds:探测超时时间,默认1秒,最小1秒。
successThreshold:探测失败后,最少连续探测成功多少次才被认定为成功。默认是 1,但是如果是`liveness`则必须是 1,最小值是 1。
failureThreshold:探测成功后,最少连续探测失败多少次才被认定为失败。默认是 3,最小值是 1。

观察是否重启

[root@master01 pod_yaml]# kubectl get pod -w
NAME                 READY   STATUS    RESTARTS   AGE
demo-pod             2/2     Running   14         6d5h
demo-pod-ssd         1/1     Running   2          4d21h
exec-health-pod      2/2     Running   0          94s
poststart-hook-pod   2/2     Running   1          86m
exec-health-pod      2/2     Running   1          2m33s

http

编写http-health-hook.yaml

cp health-hook.yaml http-health-hook.yaml 
vim http-health-hook.yaml apiVersion: v1
kind: Pod
metadata:name: http-health-podnamespace: defaultlabels:app: myapptype: pod
spec:containers:- name: myappimage: ikubernetes/myapp:v1ports:- name: httpcontainerPort: 80livenessProbe:httpGet:path: /index.htmlport: 80initialDelaySeconds: 3periodSeconds: 3- name: busyboximage: busybox:latestcommand:- "/bin/sh"- "-c"- "mkdir -p /usr/share/nginx/html; echo $(date) >> /usr/share/nginx/html/test.html;sleep 3600"

创建http-health-hook.yaml

[root@master01 pod_yaml]# kubectl apply -f http-health-hook.yaml 
pod/http-health-pod created
[root@master01 pod_yaml]# kubectl get pod -o wide
NAME                 READY   STATUS    RESTARTS   AGE     IP           NODE     NOMINATED NODE   READINESS GATES
demo-pod             2/2     Running   15         6d6h    10.244.2.7   node02   <none>           <none>
demo-pod-ssd         1/1     Running   2          4d22h   10.244.1.7   node01   <none>           <none>
http-health-pod      2/2     Running   0          3m25s   10.244.2.9   node02   <none>           <none>
poststart-hook-pod   2/2     Running   2          148m    10.244.1.8   node01   <none>           <none>
[root@master01 pod_yaml]# curl 10.244.2.9
Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>

手动删除index.html文件 观察是否重启

[root@master01 pod_yaml]# kubectl exec http-health-pod -c myapp -it -- /bin/sh
/ # cd /usr/share/nginx/html/
/usr/share/nginx/html # rm -rf index.html 
/usr/share/nginx/html # command terminated with exit code 137
[root@master01 pod_yaml]# 
[root@master01 pod_yaml]# kubectl get pod -o wide
NAME                 READY   STATUS    RESTARTS   AGE     IP           NODE     NOMINATED NODE   READINESS GATES
demo-pod             2/2     Running   15         6d6h    10.244.2.7   node02   <none>           <none>
demo-pod-ssd         1/1     Running   2          4d22h   10.244.1.7   node01   <none>           <none>
http-health-pod      2/2     Running   1          6m57s   10.244.2.9   node02   <none>           <none>
poststart-hook-pod   2/2     Running   2          151m    10.244.1.8   node01   <none>           <none>

tcpSocket

编写tcpsocket-health-hook.yaml

cp health-hook.yaml tcpsocket-health-hook.yaml 
vim tcpsocket-health-hook.yaml apiVersion: v1
kind: Pod
metadata:name: tcpsocket-health-podnamespace: defaultlabels:app: myapptype: pod
spec:containers:- name: myappimage: ikubernetes/myapp:v1ports:- name: httpcontainerPort: 80livenessProbe:tcpSocket:port: 80initialDelaySeconds: 15periodSeconds: 20- name: busyboximage: busybox:latestcommand:- "/bin/sh"- "-c"- "mkdir -p /usr/share/nginx/html; echo $(date) >> /usr/share/nginx/html/test.html;sleep 3600"

创建tcpsocket-health-hook.yaml

[root@master01 pod_yaml]# kubectl apply -f tcpsocket-health-hook.yaml 
pod/tcpsocket-health-pod created
[root@master01 pod_yaml]# kubectl get pod -o wide
NAME                   READY   STATUS    RESTARTS   AGE     IP            NODE     NOMINATED NODE   READINESS GATES
demo-pod               2/2     Running   15         6d6h    10.244.2.7    node02   <none>           <none>
demo-pod-ssd           1/1     Running   2          4d22h   10.244.1.7    node01   <none>           <none>
http-health-pod        2/2     Running   1          14m     10.244.2.9    node02   <none>           <none>
poststart-hook-pod     2/2     Running   2          159m    10.244.1.8    node01   <none>           <none>
tcpsocket-health-pod   2/2     Running   0          25s     10.244.1.10   node01   <none>           <none>

手动关掉nginx,查看是否重启

[root@master01 pod_yaml]# kubectl exec tcpsocket-health-pod -c myapp -it -- /bin/sh
/ # nginx -s stop
2019/04/06 11:25:42 [notice] 12#12: signal process started
/ # command terminated with exit code 137
[root@master01 pod_yaml]# kubectl get pod -o wide
NAME                   READY   STATUS    RESTARTS   AGE     IP            NODE     NOMINATED NODE   READINESS GATES
demo-pod               2/2     Running   15         6d6h    10.244.2.7    node02   <none>           <none>
demo-pod-ssd           1/1     Running   2          4d22h   10.244.1.7    node01   <none>           <none>
http-health-pod        2/2     Running   1          16m     10.244.2.9    node02   <none>           <none>
poststart-hook-pod     2/2     Running   2          160m    10.244.1.8    node01   <none>           <none>
tcpsocket-health-pod   2/2     Running   1          106s    10.244.1.10   node01   <none>           <none>

readiness probe

exec

编写exec-ready-hook.yaml

cp exec-health-hook.yaml exec-ready-hook.yaml 
vim exec-ready-hook.yaml apiVersion: v1
kind: Pod
metadata:name: exec-ready-podnamespace: defaultlabels:app: myapptype: pod
spec:containers:- name: myappimage: ikubernetes/myapp:v1ports:- name: httpcontainerPort: 80- name: busyboximage: busybox:latestcommand:- "/bin/sh"- "-c"- "touch /tmp/health; sleep 30; rm -rf /tmp/healthy; sleep 600"readinessProbe:exec:command: ["cat /tmp/health"]initialDelaySeconds: 5periodSeconds: 5

创建exec-ready-hook.yaml

[root@master01 pod_yaml]# kubectl apply -f exec-ready-hook.yaml 
pod/exec-health-pod created
[root@master01 pod_yaml]# kubectl get pod -o wide
NAME                   READY   STATUS    RESTARTS   AGE     IP            NODE     NOMINATED NODE   READINESS GATES
demo-pod               2/2     Running   16         6d6h    10.244.2.7    node02   <none>           <none>
demo-pod-ssd           1/1     Running   2          4d22h   10.244.1.7    node01   <none>           <none>
exec-health-pod        1/2     Running   0          3m30s   10.244.2.10   node02   <none>           <none>
exec-ready-pod         2/2     Running   0          47s     10.244.1.11   node01   <none>           <none>
http-health-pod        2/2     Running   1          27m     10.244.2.9    node02   <none>           <none>
poststart-hook-pod     2/2     Running   2          172m    10.244.1.8    node01   <none>           <none>
tcpsocket-health-pod   2/2     Running   1          13m     10.244.1.10   node01   <none>           <none>

查看pod是否就绪

[root@master01 pod_yaml]# kubectl get pod -o wide -w
NAME                   READY   STATUS    RESTARTS   AGE     IP            NODE     NOMINATED NODE   READINESS GATES
demo-pod               2/2     Running   16         6d6h    10.244.2.7    node02   <none>           <none>
demo-pod-ssd           1/1     Running   2          4d22h   10.244.1.7    node01   <none>           <none>
exec-health-pod        1/2     Running   0          3m30s   10.244.2.10   node02   <none>           <none>
exec-ready-pod         1/2     Running   0          47s     10.244.1.11   node01   <none>           <none>
http-health-pod        2/2     Running   1          27m     10.244.2.9    node02   <none>           <none>
poststart-hook-pod     2/2     Running   2          172m    10.244.1.8    node01   <none>           <none>
tcpsocket-health-pod   2/2     Running   1          13m     10.244.1.10   node01   <none>           <none>[root@master01 pod_yaml]# kubectl describe pod exec-ready-pod 
Name:               exec-ready-pod
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               node01/192.168.48.201
Start Time:         Sat, 06 Apr 2019 19:36:39 +0800
Labels:             app=myapptype=pod
Annotations:        cni.projectcalico.org/podIP: 10.244.1.11/32kubectl.kubernetes.io/last-applied-configuration:{"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"labels":{"app":"myapp","type":"pod"},"name":"exec-ready-pod","namespace":"de...
Status:             Running
IP:                 10.244.1.11
Containers:myapp:Container ID:   docker://1eff9a86d080d66b97444326053bac735f9914c53bff2a42db9eb5d392294b4dImage:          ikubernetes/myapp:v1Image ID:       docker-pullable://ikubernetes/myapp@sha256:9c3dc30b5219788b2b8a4b065f548b922a34479577befb54b03330999d30d513Port:           80/TCPHost Port:      0/TCPState:          RunningStarted:      Sat, 06 Apr 2019 19:36:40 +0800Ready:          TrueRestart Count:  0Environment:    <none>Mounts:/var/run/secrets/kubernetes.io/serviceaccount from default-token-f9699 (ro)busybox:Container ID:  docker://b411a4285635a04810a138d6029025273299023470c45b8ca7f42ddd04a8f0a4Image:         busybox:latestImage ID:      docker-pullable://busybox@sha256:954e1f01e80ce09d0887ff6ea10b13a812cb01932a0781d6b0cc23f743a874fdPort:          <none>Host Port:     <none>Command:/bin/sh-ctouch /tmp/health; sleep 30; rm -rf /tmp/healthy; sleep 600State:          RunningStarted:      Sat, 06 Apr 2019 19:37:05 +0800Ready:          FalseRestart Count:  0Readiness:      exec [cat /tmp/health] delay=5s timeout=1s period=5s #success=1 #failure=3Environment:    <none>Mounts:/var/run/secrets/kubernetes.io/serviceaccount from default-token-f9699 (ro)
Conditions:Type              StatusInitialized       True Ready             False ContainersReady   False PodScheduled      True 
Volumes:default-token-f9699:Type:        Secret (a volume populated by a Secret)SecretName:  default-token-f9699Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300snode.kubernetes.io/unreachable:NoExecute for 300s
Events:Type     Reason     Age                   From               Message----     ------     ----                  ----               -------Normal   Scheduled  3m11s                 default-scheduler  Successfully assigned default/exec-ready-pod to node01Normal   Pulled     3m10s                 kubelet, node01    Container image "ikubernetes/myapp:v1" already present on machineNormal   Created    3m10s                 kubelet, node01    Created container myappNormal   Started    3m10s                 kubelet, node01    Started container myappNormal   Pulling    3m10s                 kubelet, node01    Pulling image "busybox:latest"Normal   Pulled     2m45s                 kubelet, node01    Successfully pulled image "busybox:latest"Normal   Created    2m45s                 kubelet, node01    Created container busyboxNormal   Started    2m45s                 kubelet, node01    Started container busyboxWarning  Unhealthy  71s (x18 over 2m36s)  kubelet, node01    Readiness probe failed: OCI runtime exec failed: exec failed: container_linux.go:345: starting container process caused "exec: \"cat /tmp/health\": stat cat /tmp/health: no such file or directory": unknown

http

编写http-ready-hook.yaml

cp http-health-hook.yaml http-ready-hook.yaml 
vim http-ready-hook.yaml apiVersion: v1
kind: Pod
metadata:name: http-ready-podnamespace: defaultlabels:app: myapptype: pod
spec:containers:- name: myappimage: ikubernetes/myapp:v1ports:- name: httpcontainerPort: 80readinessProbe:httpGet:path: /index.htmlport: 80initialDelaySeconds: 3periodSeconds: 3- name: busyboximage: busybox:latestcommand:- "/bin/sh"- "-c"- "mkdir -p /usr/share/nginx/html; echo $(date) >> /usr/share/nginx/html/test.html;sleep 3600"

创建http-ready-hook.yaml

[root@master01 pod_yaml]# kubectl apply -f http-ready-hook.yaml 
pod/http-ready-pod created
[root@master01 pod_yaml]# kubectl get pod
NAME                   READY   STATUS    RESTARTS   AGE
demo-pod               2/2     Running   16         6d7h
demo-pod-ssd           1/1     Running   2          4d23h
exec-ready-pod         1/2     Running   2          23m
http-health-pod        2/2     Running   1          50m
http-ready-pod         2/2     Running   0          2m32s
poststart-hook-pod     2/2     Running   3          3h15m
tcpsocket-health-pod   2/2     Running   1          36m

手动删除index.html文件,查看pod是否就绪

[root@master01 pod_yaml]# kubectl exec http-ready-pod -c myapp -it -- /bin/sh
/ # cd /usr/share/nginx/html/
/usr/share/nginx/html # rm -rf index.html 
/usr/share/nginx/html # 
[root@master01 pod_yaml]# kubectl get pod -o wide
NAME                   READY   STATUS    RESTARTS   AGE     IP            NODE     NOMINATED NODE   READINESS GATES
demo-pod               2/2     Running   16         6d7h    10.244.2.7    node02   <none>           <none>
demo-pod-ssd           1/1     Running   2          4d23h   10.244.1.7    node01   <none>           <none>
exec-ready-pod         1/2     Running   2          26m     10.244.1.11   node01   <none>           <none>
http-health-pod        2/2     Running   1          52m     10.244.2.9    node02   <none>           <none>
http-ready-pod         1/2     Running   0          4m58s   10.244.2.11   node02   <none>           <none>
poststart-hook-pod     2/2     Running   3          3h17m   10.244.1.8    node01   <none>           <none>
tcpsocket-health-pod   2/2     Running   1          38m     10.244.1.10   node01   <none>           <none>
[root@master01 pod_yaml]# kubectl describe pod http-ready-pod 
Name:               http-ready-pod
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               node02/192.168.48.202
Start Time:         Sat, 06 Apr 2019 19:57:42 +0800
Labels:             app=myapptype=pod
Annotations:        cni.projectcalico.org/podIP: 10.244.2.11/32kubectl.kubernetes.io/last-applied-configuration:{"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"labels":{"app":"myapp","type":"pod"},"name":"http-ready-pod","namespace":"de...
Status:             Running
IP:                 10.244.2.11
Containers:myapp:Container ID:   docker://365be76d72546b736b2e119acda1b315d5c4fa498d4e7769d49421c8639b5d01Image:          ikubernetes/myapp:v1Image ID:       docker-pullable://ikubernetes/myapp@sha256:9c3dc30b5219788b2b8a4b065f548b922a34479577befb54b03330999d30d513Port:           80/TCPHost Port:      0/TCPState:          RunningStarted:      Sat, 06 Apr 2019 19:57:43 +0800Ready:          FalseRestart Count:  0Readiness:      http-get http://:80/index.html delay=3s timeout=1s period=3s #success=1 #failure=3Environment:    <none>Mounts:/var/run/secrets/kubernetes.io/serviceaccount from default-token-f9699 (ro)busybox:Container ID:  docker://270ab33e2e6ab299e6f5dd3fc4641a72e97004a249b599e47af981dcde172cdaImage:         busybox:latestImage ID:      docker-pullable://busybox@sha256:954e1f01e80ce09d0887ff6ea10b13a812cb01932a0781d6b0cc23f743a874fdPort:          <none>Host Port:     <none>Command:/bin/sh-cmkdir -p /usr/share/nginx/html; echo $(date) >> /usr/share/nginx/html/test.html;sleep 3600State:          RunningStarted:      Sat, 06 Apr 2019 19:58:13 +0800Ready:          TrueRestart Count:  0Environment:    <none>Mounts:/var/run/secrets/kubernetes.io/serviceaccount from default-token-f9699 (ro)
Conditions:Type              StatusInitialized       True Ready             False ContainersReady   False PodScheduled      True 
Volumes:default-token-f9699:Type:        Secret (a volume populated by a Secret)SecretName:  default-token-f9699Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300snode.kubernetes.io/unreachable:NoExecute for 300s
Events:Type     Reason     Age                 From               Message----     ------     ----                ----               -------Normal   Scheduled  5m38s               default-scheduler  Successfully assigned default/http-ready-pod to node02Normal   Pulled     5m38s               kubelet, node02    Container image "ikubernetes/myapp:v1" already present on machineNormal   Created    5m38s               kubelet, node02    Created container myappNormal   Started    5m38s               kubelet, node02    Started container myappNormal   Pulling    5m38s               kubelet, node02    Pulling image "busybox:latest"Normal   Pulled     5m8s                kubelet, node02    Successfully pulled image "busybox:latest"Normal   Created    5m8s                kubelet, node02    Created container busyboxNormal   Started    5m8s                kubelet, node02    Started container busyboxWarning  Unhealthy  23s (x19 over 77s)  kubelet, node02    Readiness probe failed: HTTP probe failed with statuscode: 404

tcpsocket

编写tcpsocket-ready-hook.yaml

cp tcpsocket-health-hook.yaml tcpsocket-ready-hook.yaml 
vim tcpsocket-ready-hook.yaml apiVersion: v1
kind: Pod
metadata:name: tcpsocket-ready-podnamespace: defaultlabels:app: myapptype: pod
spec:containers:- name: myappimage: ikubernetes/myapp:v1ports:- name: httpcontainerPort: 80readinessProbe:tcpSocket:port: 80initialDelaySeconds: 15periodSeconds: 20- name: busyboximage: busybox:latestcommand:- "/bin/sh"- "-c"- "mkdir -p /usr/share/nginx/html; echo $(date) >> /usr/share/nginx/html/test.html;sleep 3600"

创建tcpsocket-ready-hook.yaml

[root@master01 pod_yaml]# kubectl apply -f tcpsocket-ready-hook.yaml 
pod/tcpsocket-ready-pod created
[root@master01 pod_yaml]# kubectl get pod  -o wide
NAME                           READY   STATUS    RESTARTS   AGE     IP           NODE     NOMINATED NODE   READINESS GATES
demo-deploy-8675c97685-vhncn   1/1     Running   0          6d8h    10.244.2.5   node02   <none>           <none>
demo-deploy-8675c97685-w7md2   1/1     Running   0          6d8h    10.244.1.5   node01   <none>           <none>
demo-pod                       2/2     Running   2          6d8h    10.244.2.4   node02   <none>           <none>
tcpsocket-ready-pod            2/2     Running   0          8m47s   10.244.1.6   node01   <none>           <none>

手动改80端口,改成89,再看看是否就绪

[root@master01 pod_yaml]# kubectl exec tcpsocket-ready-pod -it -c myapp -- /bin/sh
~ # cd /etc/nginx/
/etc/nginx # cd conf.d/
/etc/nginx/conf.d # vi default.conf 
/etc/nginx/conf.d # nginx -s reload
2019/04/06 13:17:17 [notice] 19#19: signal process started
/etc/nginx/conf.d # netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:89              0.0.0.0:*               LISTEN      1/nginx: master pro[root@master01 pod_yaml]# kubectl get pod -o wide
NAME                           READY   STATUS    RESTARTS   AGE    IP           NODE     NOMINATED NODE   READINESS GATES
demo-deploy-8675c97685-vhncn   1/1     Running   0          6d8h   10.244.2.5   node02   <none>           <none>
demo-deploy-8675c97685-w7md2   1/1     Running   0          6d8h   10.244.1.5   node01   <none>           <none>
demo-pod                       1/2     Running   2          6d8h   10.244.2.4   node02   <none>           <none>
tcpsocket-ready-pod            1/2     Running   0          16m    10.244.1.6   node01   <none>           <none>[root@master01 pod_yaml]# kubectl describe pod tcpsocket-ready-pod 
Name:               tcpsocket-ready-pod
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               node01/192.168.48.201
Start Time:         Sat, 06 Apr 2019 21:04:50 +0800
Labels:             app=myapptype=pod
Annotations:        kubectl.kubernetes.io/last-applied-configuration:{"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"labels":{"app":"myapp","type":"pod"},"name":"tcpsocket-ready-pod","namespace...
Status:             Running
IP:                 10.244.1.6
Containers:myapp:Container ID:   docker://882eb554046e9f7158edb993eba6d8571af8e87ffed697a4b57afc836ad48015Image:          ikubernetes/myapp:v1Image ID:       docker-pullable://ikubernetes/myapp@sha256:9c3dc30b5219788b2b8a4b065f548b922a34479577befb54b03330999d30d513Port:           80/TCPHost Port:      0/TCPState:          RunningStarted:      Sat, 06 Apr 2019 21:04:51 +0800Ready:          FalseRestart Count:  0Readiness:      tcp-socket :80 delay=15s timeout=1s period=20s #success=1 #failure=3Environment:    <none>Mounts:/var/run/secrets/kubernetes.io/serviceaccount from default-token-f9699 (ro)busybox:Container ID:  docker://dbff1eb869afd6c15e205d6c8d8316eeb3126a82fbb2217a0fa9ce11a1bde06eImage:         busybox:latestImage ID:      docker-pullable://busybox@sha256:954e1f01e80ce09d0887ff6ea10b13a812cb01932a0781d6b0cc23f743a874fdPort:          <none>Host Port:     <none>Command:/bin/sh-cmkdir -p /usr/share/nginx/html; echo $(date) >> /usr/share/nginx/html/test.html;sleep 3600State:          RunningStarted:      Sat, 06 Apr 2019 21:11:07 +0800Ready:          TrueRestart Count:  0Environment:    <none>Mounts:/var/run/secrets/kubernetes.io/serviceaccount from default-token-f9699 (ro)
Conditions:Type              StatusInitialized       True Ready             False ContainersReady   False PodScheduled      True 
Volumes:default-token-f9699:Type:        Secret (a volume populated by a Secret)SecretName:  default-token-f9699Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300snode.kubernetes.io/unreachable:NoExecute for 300s
Events:Type     Reason     Age                  From               Message----     ------     ----                 ----               -------Normal   Scheduled  16m                  default-scheduler  Successfully assigned default/tcpsocket-ready-pod to node01Normal   Created    16m                  kubelet, node01    Created container myappNormal   Started    16m                  kubelet, node01    Started container myappNormal   Pulled     16m                  kubelet, node01    Container image "ikubernetes/myapp:v1" already present on machineWarning  Failed     13m                  kubelet, node01    Failed to pull image "busybox:latest": rpc error: code = Unknown desc = Error response from daemon: Get https://registry-1.docker.io/v2/library/busybox/manifests/latest: read tcp 192.168.48.201:35494->52.22.201.61:443: read: connection reset by peerWarning  Failed     11m (x3 over 14m)    kubelet, node01    Error: ErrImagePullWarning  Failed     11m (x2 over 14m)    kubelet, node01    Failed to pull image "busybox:latest": rpc error: code = Unknown desc = context canceledWarning  Failed     10m (x5 over 14m)    kubelet, node01    Error: ImagePullBackOffNormal   BackOff    10m (x5 over 14m)    kubelet, node01    Back-off pulling image "busybox:latest"Normal   Pulling    10m (x4 over 16m)    kubelet, node01    Pulling image "busybox:latest"Normal   Pulled     10m                  kubelet, node01    Successfully pulled image "busybox:latest"Normal   Created    10m                  kubelet, node01    Created container busyboxNormal   Started    10m                  kubelet, node01    Started container busyboxWarning  Unhealthy  92s (x8 over 3m52s)  kubelet, node01    Readiness probe failed: dial tcp 10.244.1.6:80: connect: connection refused

这篇关于一起来学k8s 05.health check的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/808712

相关文章

云原生容器技术入门:Docker、K8s技术的基本原理和用途

🐇明明跟你说过:个人主页 🏅个人专栏:《未来已来:云原生之旅》🏅 🔖行路有良友,便是天堂🔖 目录 一、容器技术概述 1、什么是容器技术 2、容器技术的历史与发展 3、容器技术与虚拟机的比较 4、容器技术在云原生中的作用 二、Docker基础 1、Docker简介 2、Docker架构 3、Docker与工作原理 三、Kubernetes(k8s)基础 1、

k8s集群master故障恢复笔记

剔除故障节点 kubectl drain master故障节点 kubectl delete node master故障节点 kubeadm reset rm -rf /etc/kubernetes/manifests mkdir -p /etc/kubernetes/pki/etcd/ 从master其他节点拷 scp /etc/kubernetes/pki/ca.crt ca.k

【K8S运维】整理常见使用命令

*特别提醒: 文件复制类的命令,执行命令等需要谨慎确定命令执行后的效果,否则一旦出错就不可逆!!! 命令概览 序号使用场景命令格式使用样例命令使用说明1查询集群节点有多少kubectl get nodes2查询集群运行哪些podkubectl get pods -o wide -A3查询指定pod名称的pod信息kubeclt get pods -o wide -A|grep <具体pod对象

活用变量,让Postman的使用飞起来

在 Postman 中使用变量是一种非常强大的功能,它可以极大地增强 API 测试和开发的灵活性和效率。 Postman变量的类型 变量在 Postman 中可以在多个层次设置和使用,包括 全局变量环境变量集合变量局部变量(如在脚本中暂时创建的变量)。 1. 全局变量(Global Variables) 全局变量在所有集合和环境中都是可用的。适合那些在所有测试中都通用的数据。 设置全局

05 TensorFlow 2.0:CNN总结及实战

浮云爱蹉跎 流光怕寂寞 填残篇脉络 续断章因果 问今生旅途几时交错 前尘灯火 隔世传说                                                                                                                                 《流光卷》 卷积层 发现特征轮廓,实现特征提

05-5.5.3 并查集的进一步优化

👋 Hi, I’m @Beast Cheng 👀 I’m interested in photography, hiking, landscape… 🌱 I’m currently learning python, javascript, kotlin… 📫 How to reach me --> 458290771@qq.com 喜欢《数据结构》部分笔记的小伙伴可以订阅专栏,今后还会

GDK,李跳跳,再见了!还是这两款软件用起来爽!

软件链接:GDK,李跳跳,再见了!还是它们用起来舒服!  智慧岛 智慧岛(原名:禅师)是一款专为安卓用户设计的应用体验提升工具。它通过一系列智能化功能,让用户在使用各种应用时更加便捷和高效。可以去除软件的开屏广告和内置广告,软件内置规则,有想去的广告软件内并没有内置规则的话,可在软件内云端搜索。 自动跳广告:智慧岛能够自动识别并跳过应用启动页的广告,为用户节省宝贵的时间,同时提升应用的流

【云原生】Docker可视化工具Portainer使用详解

目录 一、前言 二、docker可视化管理概述​​​​​​​ 2.1 什么是docker可视化管理 2.1.1 Docker可视化管理常用功能 2.2 为什么需要docker可视化管理工具 2.3 docker可视化工具带来的好处 三、常用的docker容器可视化管理工具解决方案 3.1 Portainer 3.2 Rancher 3.2.1 Rancher功能特性 3.

K8S - 实现statefulset 有状态service的灰度发布

什么是灰度发布 Canary Release 参考 理解 什么是 滚动更新,蓝绿部署,灰度发布 以及它们的区别 配置partition in updateStrategy/rollingUpdate 这次我为修改了 statefulset 的1个yaml file statefulsets/stateful-nginx-without-pvc.yaml: ---apiVersio

Pip换源秘籍:让你的Python包飞行起来!

在Python的包管理中,Pip是最重要的工具之一。它允许开发者从Python Package Index (PyPI)安装包,但有时由于网络问题或服务器负载过高,直接从PyPI安装包可能会非常慢。这时,更换Pip源到一个更快的镜像站点是一个常见的解决方案。本文将全面介绍Pip换源的基本概念、使用方法、主要作用以及注意事项。 一、Pip换源简介 1. Pip的起源 Pip是Pytho