zoukankan      html  css  js  c++  java
  • 【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 最长的运行时间。

    附录

  • 相关阅读:
    hdu 2665 划分树
    概率模型与条件随机场
    shell中各种括号的作用()、(())、[]、[[]]、{}
    今日BBC
    小贝_mysql主从复制作用以及案例
    c++ builder 版CreateAnonymousThread用法
    安卓UI适配限定符
    编译3.10内核 出现错误 “undefined reference to....&quot; 解决方法
    iptables的4表5链(未完)
    已有iptables表的查看
  • 原文地址:https://www.cnblogs.com/jiangbo44/p/14587598.html
Copyright © 2011-2022 走看看