小编acm*_*acm的帖子

pod PreStop 钩子挂在 Termination 状态,仅在 TerminationGracePeriodSeconds 后被终止

我在有状态 Pod 资源中定义了一个 preStop 钩子,该钩子运行 bash 脚本,以确保在应用程序中少数进程完成/取消/错误之前不会终止 Pod。我没有定义终止GracePeriodSeconds。现在,当我删除 pod 时,我测试了 preStop 挂钩中的脚本是否按预期运行。但添加终止GracePeriodSeconds 10 分钟后,首先 bash 脚本作为 preStop 挂钩的一部分成功运行几分钟,并且应该会杀死 pod。但 Pod 处于 TERMINATING 状态,并且仅在 10 分钟后就被杀死。

  1. 为什么 Pod 挂了?无法找到这个问题的答案。
  2. 当未添加 TerminationGracePeriodSeconds 时,流程会按预期工作,在完成脚本后或在 30 秒(即 TerminationGracePeriodSeconds)内终止 pod。但是当我添加 10 分钟或更长的宽限期时,它会等到那个时间然后杀死 pod。

如何解决这个问题。有没有办法将 SIGTERM 或 SIGKILL 发送到 pod。有任何想法吗?先感谢您!

状态集.YAML

apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app: appx
  name: appx
spec:
  serviceName: appx
  replicas: 1
  updateStrategy:
    type: RollingUpdate
  selector:
    matchLabels:
      app: appx
  template:
    metadata:
      labels:
        app: appx
    spec:
      #removed some of the sensitive info
      terminationGracePeriodSeconds: …
Run Code Online (Sandbox Code Playgroud)

sigterm kubernetes

2
推荐指数
1
解决办法
3645
查看次数

标签 统计

kubernetes ×1

sigterm ×1