【k8s】Pod-activeDeadlineSeconds


環境

  1. kubernetes 1.20.4
  2. Spring Boot 2.5.0-M3

目標

activeDeadlineSeconds 表示 Pod 可以運行的最長時間,達到設置的該值后,Pod 會自動停止。

示例

Pod.yaml

apiVersion: v1
kind: Pod
metadata:
  name: spring-k8s
spec:
  activeDeadlineSeconds: 30
  containers:
    - name: spring-k8s
      image: jiangbo920827/spring-k8s:liveness
      ports:
        - containerPort: 8080

查看 Pod

[root@master ~]# kubectl get pod
NAME         READY   STATUS    RESTARTS   AGE
spring-k8s   1/1     Running   0          9s
[root@master ~]# kubectl get pod --watch
NAME         READY   STATUS    RESTARTS   AGE
spring-k8s   1/1     Running   0          14s
spring-k8s   0/1     DeadlineExceeded   0          30s

describe

[root@master ~]# kubectl describe pod spring-k8s
Name:         spring-k8s
Namespace:    default
Priority:     0
Node:         node2/
Start Time:   Sat, 27 Mar 2021 23:09:18 +0800
Labels:       <none>
Annotations:  <none>
Status:       Failed
Reason:       DeadlineExceeded
Message:      Pod was active on the node longer than the specified deadline
IP:           10.244.2.164
IPs:
  IP:  10.244.2.164
...

Events:
  Type    Reason            Age                From               Message
  ----    ------            ----               ----               -------
  Normal  Scheduled         118s               default-scheduler  Successfully assigned default/spring-k8s to node2
  Normal  Pulled            113s               kubelet            Container image "jiangbo920827/spring-k8s:liveness" already present on machine
  Normal  Created           113s               kubelet            Created container spring-k8s
  Normal  Started           113s               kubelet            Started container spring-k8s
  Normal  Killing           89s                kubelet            Stopping container spring-k8s
  Normal  DeadlineExceeded  87s (x3 over 89s)  kubelet            Pod was active on the node longer than the specified deadline

總結

activeDeadlineSeconds 可以設置 Pod 最長的運行時間。

附錄


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM