首页 > 解决方案 > 如何在 EKS 中保持我的 pod 运行(不终止/重新启动)

问题描述

我正在尝试使用 AWS EKS (fargate) 运行自动化案例,但是一些 pod(运行 10 次中有 9 次)被终止,导致自动化失败。

我有一堆用robotframework写的自动化案例,案例本身运行良好,但是比较耗时,一般需要6个小时才能完成一轮。所以,我认为我可以使用 K8S 并行运行案例,从而节省时间,我使用 Jenkins 来配置并行运行的“自动化”数量,完成后合并并呈现测试结果。

但是有些豆荚会被终止,

命令“kubectl get pod”,返回类似这样的内容(我设置了“restartPolicy:Never”以保持错误 pod 以“描述”其信息,否则,pod 就消失了)

box6           0/1     Error     0          9m39s

命令“kubectl describe pod box6”得到如下输出(屏蔽了一些私人信息)。

Name:                 box6
Namespace:            default
Priority:             2000001000
Priority Class Name:  system-node-critical
Node:                 XXXXXXXX
Start Time:           Mon, 21 Dec 2020 15:29:37 +0800
Labels:               eks.amazonaws.com/fargate-profile=eksautomation-profile
                      name=box6
                      purpose=demonstrate-command
Annotations:          CapacityProvisioned: 0.25vCPU 0.5GB
                      Logging: LoggingDisabled: LOGGING_CONFIGMAP_NOT_FOUND
                      kubectl.kubernetes.io/last-applied-configuration:
                        {"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"labels":{"name":"box6","purpose":"demonstrate-command"},"name":"box6","names...
                      kubernetes.io/psp: eks.privileged
Status:               Failed
IP:                   192.168.183.226
IPs:
  IP:  192.168.183.226
Containers:
  box6:
    Container ID:  XXXXXXXX
    Image:         XXXXXXXX
    Image ID:      XXXXXXXX
    Port:          <none>
    Host Port:     <none>
    Command:
      /bin/initMock.sh
    State:          Terminated
      Reason:       Error
      Exit Code:    143
      Started:      Mon, 21 Dec 2020 15:32:12 +0800
      Finished:     Mon, 21 Dec 2020 15:34:09 +0800
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-tsk7j (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  default-token-tsk7j:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-tsk7j
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason           Age        From                                                            Message
  ----     ------           ----       ----                                                            -------
  Warning  LoggingDisabled  <unknown>  fargate-scheduler                                               Disabled logging because aws-logging configmap was not found. configmap "aws-logging" not found
  Normal   Scheduled        <unknown>  fargate-scheduler                                               Successfully assigned default/box6 to XXXXXXXX
  Normal   Pulling          5m7s       kubelet, XXXXXXXX  Pulling image "XXXXXXXX"
  Normal   Pulled           2m38s      kubelet, XXXXXXXX  Successfully pulled image "XXXXXXXX"
  Normal   Created          2m38s      kubelet, XXXXXXXX  Created container box6
  Normal   Started          2m37s      kubelet, XXXXXXXX  Started container box6

我对错误进行了一些搜索,错误代码 143 是 128+SIGTERM,我怀疑 pod 是否被 EKS 故意杀死。

我无法将 pod 配置为重新启动,因为如果这样,自动化案例将无法恢复,因此使努力无用(无法节省自动化运行时间)。

我曾尝试启用云监视,希望能找到关于 pod 为何终止的线索,但没有任何线索。

为什么我的 pod 会被 EKS 终止?我应该如何对其进行故障排除?我应该如何避免它?

谢谢你的帮助。

标签: kubernetesamazon-eks

解决方案


推荐阅读