Kubernetes kubectl显示Pod重新启动为零,但Pod的年龄已更改

时间:2018-07-24 10:44:11

标签: kubernetes kubectl

有人可以解释为什么以下命令显示没有重新启动,但是启动17天前的时间是2小时

kubectl get pod -o wide
NAME                  READY     STATUS    RESTARTS   AGE       IP                NODE
api-depl-nm-xxx       1/1       Running   0          17d       xxx.xxx.xxx.xxx   ip-xxx-xxx-xxx-xxx.eu-west-1.compute.internal
ei-depl-nm-xxx        1/1       Running   0          2h        xxx.xxx.xxx.xxx   ip-xxx-xxx-xxx-xxx.eu-west-1.compute.internal
jenkins-depl-nm-xxx   1/1       Running   0          2h        xxx.xxx.xxx.xxx   ip-xxx-xxx-xxx-xxx.eu-west-1.compute.internal

部署已经运行了17天:

kubectl get deploy -o wide
NAME              DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE       CONTAINER(S)      IMAGE(S) SELECTOR                                                          
api-depl-nm       1         1         1            1           17d       api-depl-nm       xxx   name=api-depl-nm
ei-depl-nm        1         1         1            1           17d       ei-depl-nm        xxx   name=ei-depl-nm
jenkins-depl-nm   1         1         1            1           17d       jenkins-depl-nm   xxx   name=jenkins-depl-nm

开始时间是2个小时前:

kubectl describe po ei-depl-nm-xxx | grep Start
Start Time:     Tue, 24 Jul 2018 09:07:05 +0100
Started:        Tue, 24 Jul 2018 09:10:33 +0100

应用程序日志显示它已重新启动。 那么为什么重启数为0?

已更新了更多信息,作为对答案的回应。

我可能是错的,但是我不认为部署已更新或扩展过,但是肯定不是我自己做的,而且没有人可以访问该系统。

 kubectl describe deployment ei-depl-nm

 ...
CreationTimestamp:      Fri, 06 Jul 2018 17:06:24 +0100
Labels:                 name=ei-depl-nm
...
Replicas:               1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType:           RollingUpdate
...
Conditions:
  Type          Status  Reason
  ----          ------  ------
  Available     True    MinimumReplicasAvailable
OldReplicaSets: <none>
NewReplicaSet:  ei-depl-nm-xxx (1/1 replicas created)
Events:         <none>

我可能是错的,但我不认为工作节点已重新启动或关闭

kubectl describe nodes ip-xxx.eu-west-1.compute.internal

    Taints:                 <none>
CreationTimestamp:      Fri, 06 Jul 2018 16:39:40 +0100
Conditions:
  Type                  Status  LastHeartbeatTime                       LastTransitionTime                      Reason                          Message
  ----                  ------  -----------------                       ------------------                      ------                          -------
  NetworkUnavailable    False   Fri, 06 Jul 2018 16:39:45 +0100         Fri, 06 Jul 2018 16:39:45 +0100         RouteCreated                    RouteController created a route
  OutOfDisk             False   Wed, 25 Jul 2018 16:30:36 +0100         Fri, 06 Jul 2018 16:39:40 +0100         KubeletHasSufficientDisk        kubelet has sufficient disk space available
  MemoryPressure        False   Wed, 25 Jul 2018 16:30:36 +0100         Wed, 25 Jul 2018 02:23:01 +0100         KubeletHasSufficientMemory      kubelet has sufficient memory available
  DiskPressure          False   Wed, 25 Jul 2018 16:30:36 +0100         Wed, 25 Jul 2018 02:23:01 +0100         KubeletHasNoDiskPressure        kubelet has no disk pressure
  Ready                 True    Wed, 25 Jul 2018 16:30:36 +0100         Wed, 25 Jul 2018 02:23:11 +0100         KubeletReady                    kubelet is posting ready status
......
Non-terminated Pods:            (4 in total)
  Namespace                     Name                                             CPU Requests    CPU Limits      Memory Requests Memory Limits
  ---------                     ----                                                            ------------    ----------      --------------- -------------
  default                       ei-depl-nm-xxx                                     100m (5%)       0 (0%)          0 (0%)          0 (0%)
  default                       jenkins-depl-nm-xxx                                100m (5%)       0 (0%)          0 (0%)          0 (0%)
  kube-system                   kube-dns-xxx                                      260m (13%)      0 (0%)          110Mi (1%)      170Mi (2%)
  kube-system                   kube-proxy-ip-xxx.eu-west-1.compute.internal            100m (5%)       0 (0%)          0 (0%)          0 (0%)
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  CPU Requests  CPU Limits      Memory Requests Memory Limits
  ------------  ----------      --------------- -------------
  560m (28%)    0 (0%)          110Mi (1%)      170Mi (2%)
Events:         <none>

1 个答案:

答案 0 :(得分:1)

可能会发生两件事:

  1. 部署已更新或扩展:

    • 部署时间不变
    • 创建新的ReplicaSet,删除旧的ReplicaSet。您可以通过运行

      进行检查
      $ kubectl describe deployment <deployment_name>  
      ...
      Events:
        Type    Reason             Age   From                   Message
        ----    ------             ----  ----                   -------
        Normal  ScalingReplicaSet  1m    deployment-controller  Scaled up replica set testdep1-75488876f6 to 1
        Normal  ScalingReplicaSet  1m    deployment-controller  Scaled down replica set testdep1-d4884df5f to 0
      
    • 由旧的ReplicaSet创建的
    • pod被终止,新的ReplicaSet创建的全新Pod的重启时间为0,使用时间为0秒。

  2. Worker节点已重新启动或关闭。

    • 旧工作节点上的Pod消失
    • 调度程序在第一个可用节点(重新启动后可以是同一节点)上创建一个全新的Pod,重新启动时间为0秒,年龄为0秒。
    • 您可以通过运行来检查节点启动事件

      kubectl describe nodes <node_name>
      ...
       Type    Reason                   Age                From                   Message
        ----    ------                   ----               ----                   -------
        Normal  Starting                 32s                kubelet, <node-name>     Starting kubelet.
        Normal  NodeHasSufficientPID     31s (x5 over 32s)  kubelet, <node-name>     Node <node-name> status is now: NodeHasSufficientPID
        Normal  NodeAllocatableEnforced  31s                kubelet, <node-name>     Updated Node Allocatable limit across pods
        Normal  NodeHasSufficientDisk    30s (x6 over 32s)  kubelet, <node-name>     Node <node-name> status is now: NodeHasSufficientDisk
        Normal  NodeHasSufficientMemory  30s (x6 over 32s)  kubelet, <node-name>     Node <node-name> status is now: NodeHasSufficientMemory
        Normal  NodeHasNoDiskPressure    30s (x6 over 32s)  kubelet, <node-name>     Node <node-name> status is now: NodeHasNoDiskPressure
        Normal  Starting                 10s                kube-proxy, <node-name>  Starting kube-proxy.