一起来学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

相关文章

k8s部署MongDB全过程

《k8s部署MongDB全过程》文章介绍了如何在Kubernetes集群中部署MongoDB,包括环境准备、创建Secret、创建服务和Deployment,并通过Robo3T工具测试连接... 目录一、环境准备1.1 环境说明1.2 创建 namespace1.3 创建mongdb账号/密码二、创建Sec

centos7基于keepalived+nginx部署k8s1.26.0高可用集群

《centos7基于keepalived+nginx部署k8s1.26.0高可用集群》Kubernetes是一个开源的容器编排平台,用于自动化地部署、扩展和管理容器化应用程序,在生产环境中,为了确保集... 目录一、初始化(所有节点都执行)二、安装containerd(所有节点都执行)三、安装docker-

MySQL数据库宕机,启动不起来,教你一招搞定!

作者介绍:老苏,10余年DBA工作运维经验,擅长Oracle、MySQL、PG、Mongodb数据库运维(如安装迁移,性能优化、故障应急处理等)公众号:老苏畅谈运维欢迎关注本人公众号,更多精彩与您分享。 MySQL数据库宕机,数据页损坏问题,启动不起来,该如何排查和解决,本文将为你说明具体的排查过程。 查看MySQL error日志 查看 MySQL error日志,排查哪个表(表空间

90、k8s之secret+configMap

一、secret配置管理 配置管理: 加密配置:保存密码,token,其他敏感信息的k8s资源 应用配置:我们需要定制化的给应用进行配置,我们需要把定制好的配置文件同步到pod当中容器 1.1、加密配置: secret: [root@master01 ~]# kubectl get secrets ##查看加密配置[root@master01 ~]# kubectl get se

K8S(Kubernetes)开源的容器编排平台安装步骤详解

K8S(Kubernetes)是一个开源的容器编排平台,用于自动化部署、扩展和管理容器化应用程序。以下是K8S容器编排平台的安装步骤、使用方式及特点的概述: 安装步骤: 安装Docker:K8S需要基于Docker来运行容器化应用程序。首先要在所有节点上安装Docker引擎。 安装Kubernetes Master:在集群中选择一台主机作为Master节点,安装K8S的控制平面组件,如AP

忽略某些文件 —— Git 学习笔记 05

忽略某些文件 忽略某些文件 通过.gitignore文件其他规则源如何选择规则源参考资料 对于某些文件,我们不希望把它们纳入 Git 的管理,也不希望它们总出现在未跟踪文件列表。通常它们都是些自动生成的文件,比如日志文件、编译过程中创建的临时文件等。 通过.gitignore文件 假设我们要忽略 lib.a 文件,那我们可以在 lib.a 所在目录下创建一个名为 .gi

【Kubernetes】K8s 的安全框架和用户认证

K8s 的安全框架和用户认证 1.Kubernetes 的安全框架1.1 认证:Authentication1.2 鉴权:Authorization1.3 准入控制:Admission Control 2.Kubernetes 的用户认证2.1 Kubernetes 的用户认证方式2.2 配置 Kubernetes 集群使用密码认证 Kubernetes 作为一个分布式的虚拟

用Unity2D制作一个人物,实现移动、跳起、人物静止和动起来时的动画:中(人物移动、跳起、静止动作)

上回我们学到创建一个地形和一个人物,今天我们实现一下人物实现移动和跳起,依次点击,我们准备创建一个C#文件 创建好我们点击进去,就会跳转到我们的Vision Studio,然后输入这些代码 using UnityEngine;public class Move : MonoBehaviour // 定义一个名为Move的类,继承自MonoBehaviour{private Rigidbo

828华为云征文|华为云Flexus X实例docker部署rancher并构建k8s集群

828华为云征文|华为云Flexus X实例docker部署rancher并构建k8s集群 华为云最近正在举办828 B2B企业节,Flexus X实例的促销力度非常大,特别适合那些对算力性能有高要求的小伙伴。如果你有自建MySQL、Redis、Nginx等服务的需求,一定不要错过这个机会。赶紧去看看吧! 什么是华为云Flexus X实例 华为云Flexus X实例云服务是新一代开箱即用、体

SOMEIP_ETS_095: SD_Check_subscribe_eventgroup_ttl_expired

测试目的: 验证DUT(Device Under Test)能够检测到测试器(Tester)的订阅已过期(ttl = 3秒),并且在TTL过期后不响应测试器触发的事件。 描述 本测试用例旨在确保DUT能够识别测试器的订阅已过期,并在订阅过期后不响应测试器通过TriggerEventUint8方法触发的事件。 测试拓扑: 具体步骤: TESTER:发送订阅事件组消息,用于事件组0x0