kubectl 描述 pod 重启计数从什么时候开始?

问题描述 投票:0回答:1

microk8s kubectl describe pod -n <pod_name>
重启计数从什么时候开始? 我在结果中看到重新启动计数: 容器.应用程序名称.重新启动计数

例如,请参阅以下结果:

### microk8s kubectl describe pod -n kube-system hostpath-provisioner-566686b959-pmtw5
Name:         hostpath-provisioner-566686b959-pmtw5
Namespace:    kube-system
Priority:     0
Node:         ipc/192.168.1.101
Start Time:   Wed, 03 Aug 2022 10:10:26 +0000
Labels:       k8s-app=hostpath-provisioner
              pod-template-hash=566686b959
Annotations:  cni.projectcalico.org/podIP: 10.1.206.150/32
              cni.projectcalico.org/podIPs: 10.1.206.150/32
Status:       Running
IP:           10.1.206.150
IPs:
  IP:           10.1.206.150
Controlled By:  ReplicaSet/hostpath-provisioner-566686b959
Containers:
  hostpath-provisioner:
    Container ID:   containerd://f32ed83a49dc15cc4f92c4fb03685b75117436e42345364d29e0a908633cd1c7
    Image:          cdkbot/hostpath-provisioner:1.1.0
    Image ID:       docker.io/cdkbot/hostpath-provisioner@sha256:317ed1b7324dc5f20db5dfdc0647a26a1ac44df426e9caad9cfdd6ba84c47697
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Wed, 06 Nov 2024 19:54:08 +0000
    Last State:     Terminated
      Reason:       Unknown
      Exit Code:    255
      Started:      Wed, 02 Oct 2024 22:40:48 +0000
      Finished:     Wed, 06 Nov 2024 19:53:09 +0000
    Ready:          True
    Restart Count:  68
    Environment:
      NODE_NAME:   (v1:spec.nodeName)
      PV_DIR:     /var/snap/microk8s/common/default-storage
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-d2s6c (ro)
      /var/snap/microk8s/common/default-storage from pv-volume (rw)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  pv-volume:
    Type:          HostPath (bare host directory volume)
    Path:          /var/snap/microk8s/common/default-storage
    HostPathType:  
  kube-api-access-d2s6c:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:                      <none>

但是重启是从什么时候开始算的呢? 我在 kubectl 描述 pod 文档这里中没有看到这个答案。

kubernetes
1个回答
0
投票

重启次数是Pod中容器被重启的次数。在这种情况下,

hostpath-provisioner:1.1.0
已重新启动 68 次。如果 Pod 中运行另一个容器,您将能够单独看到它的重新启动计数。当容器由于错误或失败或者因为应用程序代码显式定义退出命令而退出时,就会发生重新启动。如果活动/启动探测失败,Kubernetes 将强制重新启动容器,也可能会发生这种情况。由于 Pod(与作业不同)被设计为永远运行,因此容器每次退出时都会重新启动。

© www.soinside.com 2019 - 2024. All rights reserved.