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

apiVersion: v1
kind: Pod
metadata:
  name: health-pod
  namespace: default
  labels:
    app: myapp
    type: pod
spec:
  containers:
  - name: myapp
    image: ikubernetes/myapp:v1
    ports:
    - name: http
      containerPort: 80
  - name: busybox
    image: busybox:latest
    command:
    - "/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-pod
  namespace: default
  labels:
    app: myapp
    type: pod
spec:
  containers:
  - name: myapp
    image: ikubernetes/myapp:v1
    ports:
    - name: http
      containerPort: 80
  - name: busybox
    image: busybox:latest
    command:
    - "/bin/sh"
    - "-c"
    - "touch /tmp/health; sleep 30; rm -rf /tmp/healthy; sleep 600"
    livenessProbe:
      exec:
        command: ["cat /tmp/health"]
      initialDelaySeconds: 5
      periodSeconds: 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-pod
  namespace: default
  labels:
    app: myapp
    type: pod
spec:
  containers:
  - name: myapp
    image: ikubernetes/myapp:v1
    ports:
    - name: http
      containerPort: 80
    livenessProbe:
      httpGet:
        path: /index.html
        port: 80
      initialDelaySeconds: 3
      periodSeconds: 3
  - name: busybox
    image: busybox:latest
    command:
    - "/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              
demo-pod-ssd         1/1     Running   2          4d22h   10.244.1.7   node01              
http-health-pod      2/2     Running   0          3m25s   10.244.2.9   node02              
poststart-hook-pod   2/2     Running   2          148m    10.244.1.8   node01              
[root@master01 pod_yaml]# curl 10.244.2.9
Hello MyApp | Version: v1 | Pod Name


手动删除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              
demo-pod-ssd         1/1     Running   2          4d22h   10.244.1.7   node01              
http-health-pod      2/2     Running   1          6m57s   10.244.2.9   node02              
poststart-hook-pod   2/2     Running   2          151m    10.244.1.8   node01              


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-pod
  namespace: default
  labels:
    app: myapp
    type: pod
spec:
  containers:
  - name: myapp
    image: ikubernetes/myapp:v1
    ports:
    - name: http
      containerPort: 80
    livenessProbe:
      tcpSocket:
        port: 80
      initialDelaySeconds: 15
      periodSeconds: 20
  - name: busybox
    image: busybox:latest
    command:
    - "/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              
demo-pod-ssd           1/1     Running   2          4d22h   10.244.1.7    node01              
http-health-pod        2/2     Running   1          14m     10.244.2.9    node02              
poststart-hook-pod     2/2     Running   2          159m    10.244.1.8    node01              
tcpsocket-health-pod   2/2     Running   0          25s     10.244.1.10   node01              


手动关掉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              
demo-pod-ssd           1/1     Running   2          4d22h   10.244.1.7    node01              
http-health-pod        2/2     Running   1          16m     10.244.2.9    node02              
poststart-hook-pod     2/2     Running   2          160m    10.244.1.8    node01              
tcpsocket-health-pod   2/2     Running   1          106s    10.244.1.10   node01              


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-pod
  namespace: default
  labels:
    app: myapp
    type: pod
spec:
  containers:
  - name: myapp
    image: ikubernetes/myapp:v1
    ports:
    - name: http
      containerPort: 80
  - name: busybox
    image: busybox:latest
    command:
    - "/bin/sh"
    - "-c"
    - "touch /tmp/health; sleep 30; rm -rf /tmp/healthy; sleep 600"
    readinessProbe:
      exec:
        command: ["cat /tmp/health"]
      initialDelaySeconds: 5
      periodSeconds: 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              
demo-pod-ssd           1/1     Running   2          4d22h   10.244.1.7    node01              
exec-health-pod        1/2     Running   0          3m30s   10.244.2.10   node02              
exec-ready-pod         2/2     Running   0          47s     10.244.1.11   node01              
http-health-pod        2/2     Running   1          27m     10.244.2.9    node02              
poststart-hook-pod     2/2     Running   2          172m    10.244.1.8    node01              
tcpsocket-health-pod   2/2     Running   1          13m     10.244.1.10   node01              


查看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              
demo-pod-ssd           1/1     Running   2          4d22h   10.244.1.7    node01              
exec-health-pod        1/2     Running   0          3m30s   10.244.2.10   node02              
exec-ready-pod         1/2     Running   0          47s     10.244.1.11   node01              
http-health-pod        2/2     Running   1          27m     10.244.2.9    node02              
poststart-hook-pod     2/2     Running   2          172m    10.244.1.8    node01              
tcpsocket-health-pod   2/2     Running   1          13m     10.244.1.10   node01              

[root@master01 pod_yaml]# kubectl describe pod exec-ready-pod 
Name:               exec-ready-pod
Namespace:          default
Priority:           0
PriorityClassName:  
Node:               node01/192.168.48.201
Start Time:         Sat, 06 Apr 2019 19:36:39 +0800
Labels:             app=myapp
                    type=pod
Annotations:        cni.projectcalico.org/podIP: 10.244.1.11/32
                    kubectl.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://1eff9a86d080d66b97444326053bac735f9914c53bff2a42db9eb5d392294b4d
    Image:          ikubernetes/myapp:v1
    Image ID:       docker-pullable://ikubernetes/myapp@sha256:9c3dc30b5219788b2b8a4b065f548b922a34479577befb54b03330999d30d513
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Sat, 06 Apr 2019 19:36:40 +0800
    Ready:          True
    Restart Count:  0
    Environment:    
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-f9699 (ro)
  busybox:
    Container ID:  docker://b411a4285635a04810a138d6029025273299023470c45b8ca7f42ddd04a8f0a4
    Image:         busybox:latest
    Image ID:      docker-pullable://busybox@sha256:954e1f01e80ce09d0887ff6ea10b13a812cb01932a0781d6b0cc23f743a874fd
    Port:          
    Host Port:     
    Command:
      /bin/sh
      -c
      touch /tmp/health; sleep 30; rm -rf /tmp/healthy; sleep 600
    State:          Running
      Started:      Sat, 06 Apr 2019 19:37:05 +0800
    Ready:          False
    Restart Count:  0
    Readiness:      exec [cat /tmp/health] delay=5s timeout=1s period=5s #success=1 #failure=3
    Environment:    
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-f9699 (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  default-token-f9699:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-f9699
    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  3m11s                 default-scheduler  Successfully assigned default/exec-ready-pod to node01
  Normal   Pulled     3m10s                 kubelet, node01    Container image "ikubernetes/myapp:v1" already present on machine
  Normal   Created    3m10s                 kubelet, node01    Created container myapp
  Normal   Started    3m10s                 kubelet, node01    Started container myapp
  Normal   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 busybox
  Normal   Started    2m45s                 kubelet, node01    Started container busybox
  Warning  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-pod
  namespace: default
  labels:
    app: myapp
    type: pod
spec:
  containers:
  - name: myapp
    image: ikubernetes/myapp:v1
    ports:
    - name: http
      containerPort: 80
    readinessProbe:
      httpGet:
        path: /index.html
        port: 80
      initialDelaySeconds: 3
      periodSeconds: 3
  - name: busybox
    image: busybox:latest
    command:
    - "/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              
demo-pod-ssd           1/1     Running   2          4d23h   10.244.1.7    node01              
exec-ready-pod         1/2     Running   2          26m     10.244.1.11   node01              
http-health-pod        2/2     Running   1          52m     10.244.2.9    node02              
http-ready-pod         1/2     Running   0          4m58s   10.244.2.11   node02              
poststart-hook-pod     2/2     Running   3          3h17m   10.244.1.8    node01              
tcpsocket-health-pod   2/2     Running   1          38m     10.244.1.10   node01              
[root@master01 pod_yaml]# kubectl describe pod http-ready-pod 
Name:               http-ready-pod
Namespace:          default
Priority:           0
PriorityClassName:  
Node:               node02/192.168.48.202
Start Time:         Sat, 06 Apr 2019 19:57:42 +0800
Labels:             app=myapp
                    type=pod
Annotations:        cni.projectcalico.org/podIP: 10.244.2.11/32
                    kubectl.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://365be76d72546b736b2e119acda1b315d5c4fa498d4e7769d49421c8639b5d01
    Image:          ikubernetes/myapp:v1
    Image ID:       docker-pullable://ikubernetes/myapp@sha256:9c3dc30b5219788b2b8a4b065f548b922a34479577befb54b03330999d30d513
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Sat, 06 Apr 2019 19:57:43 +0800
    Ready:          False
    Restart Count:  0
    Readiness:      http-get http://:80/index.html delay=3s timeout=1s period=3s #success=1 #failure=3
    Environment:    
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-f9699 (ro)
  busybox:
    Container ID:  docker://270ab33e2e6ab299e6f5dd3fc4641a72e97004a249b599e47af981dcde172cda
    Image:         busybox:latest
    Image ID:      docker-pullable://busybox@sha256:954e1f01e80ce09d0887ff6ea10b13a812cb01932a0781d6b0cc23f743a874fd
    Port:          
    Host Port:     
    Command:
      /bin/sh
      -c
      mkdir -p /usr/share/nginx/html; echo $(date) >> /usr/share/nginx/html/test.html;sleep 3600
    State:          Running
      Started:      Sat, 06 Apr 2019 19:58:13 +0800
    Ready:          True
    Restart Count:  0
    Environment:    
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-f9699 (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  default-token-f9699:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-f9699
    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  5m38s               default-scheduler  Successfully assigned default/http-ready-pod to node02
  Normal   Pulled     5m38s               kubelet, node02    Container image "ikubernetes/myapp:v1" already present on machine
  Normal   Created    5m38s               kubelet, node02    Created container myapp
  Normal   Started    5m38s               kubelet, node02    Started container myapp
  Normal   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 busybox
  Normal   Started    5m8s                kubelet, node02    Started container busybox
  Warning  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-pod
  namespace: default
  labels:
    app: myapp
    type: pod
spec:
  containers:
  - name: myapp
    image: ikubernetes/myapp:v1
    ports:
    - name: http
      containerPort: 80
    readinessProbe:
      tcpSocket:
        port: 80
      initialDelaySeconds: 15
      periodSeconds: 20
  - name: busybox
    image: busybox:latest
    command:
    - "/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              
demo-deploy-8675c97685-w7md2   1/1     Running   0          6d8h    10.244.1.5   node01              
demo-pod                       2/2     Running   2          6d8h    10.244.2.4   node02              
tcpsocket-ready-pod            2/2     Running   0          8m47s   10.244.1.6   node01              


手动改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              
demo-deploy-8675c97685-w7md2   1/1     Running   0          6d8h   10.244.1.5   node01              
demo-pod                       1/2     Running   2          6d8h   10.244.2.4   node02              
tcpsocket-ready-pod            1/2     Running   0          16m    10.244.1.6   node01              

[root@master01 pod_yaml]# kubectl describe pod tcpsocket-ready-pod 
Name:               tcpsocket-ready-pod
Namespace:          default
Priority:           0
PriorityClassName:  
Node:               node01/192.168.48.201
Start Time:         Sat, 06 Apr 2019 21:04:50 +0800
Labels:             app=myapp
                    type=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://882eb554046e9f7158edb993eba6d8571af8e87ffed697a4b57afc836ad48015
    Image:          ikubernetes/myapp:v1
    Image ID:       docker-pullable://ikubernetes/myapp@sha256:9c3dc30b5219788b2b8a4b065f548b922a34479577befb54b03330999d30d513
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Sat, 06 Apr 2019 21:04:51 +0800
    Ready:          False
    Restart Count:  0
    Readiness:      tcp-socket :80 delay=15s timeout=1s period=20s #success=1 #failure=3
    Environment:    
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-f9699 (ro)
  busybox:
    Container ID:  docker://dbff1eb869afd6c15e205d6c8d8316eeb3126a82fbb2217a0fa9ce11a1bde06e
    Image:         busybox:latest
    Image ID:      docker-pullable://busybox@sha256:954e1f01e80ce09d0887ff6ea10b13a812cb01932a0781d6b0cc23f743a874fd
    Port:          
    Host Port:     
    Command:
      /bin/sh
      -c
      mkdir -p /usr/share/nginx/html; echo $(date) >> /usr/share/nginx/html/test.html;sleep 3600
    State:          Running
      Started:      Sat, 06 Apr 2019 21:11:07 +0800
    Ready:          True
    Restart Count:  0
    Environment:    
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-f9699 (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  default-token-f9699:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-f9699
    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  16m                  default-scheduler  Successfully assigned default/tcpsocket-ready-pod to node01
  Normal   Created    16m                  kubelet, node01    Created container myapp
  Normal   Started    16m                  kubelet, node01    Started container myapp
  Normal   Pulled     16m                  kubelet, node01    Container image "ikubernetes/myapp:v1" already present on machine
  Warning  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 peer
  Warning  Failed     11m (x3 over 14m)    kubelet, node01    Error: ErrImagePull
  Warning  Failed     11m (x2 over 14m)    kubelet, node01    Failed to pull image "busybox:latest": rpc error: code = Unknown desc = context canceled
  Warning  Failed     10m (x5 over 14m)    kubelet, node01    Error: ImagePullBackOff
  Normal   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 busybox
  Normal   Started    10m                  kubelet, node01    Started container busybox
  Warning  Unhealthy  92s (x8 over 3m52s)  kubelet, node01    Readiness probe failed: dial tcp 10.244.1.6:80: connect: connection refused


你可能感兴趣的:(kubernetes)