preStop 钩子和 terminationGracePeriodSeconds 之间的关系
Relation between preStop hook and terminationGracePeriodSeconds
基本上我想做的是尝试 pod 生命周期并检查我们是否可以做一些 cleanup/backup 例如在 pod 终止之前复制日志。
我需要什么:
在终止
之前将 logs/heapdumps 从容器复制到 hostPath/S3
我尝试了什么:
我使用带有 bash 命令的 preStop 挂钩来回显一条消息(只是为了看看它是否有效!!)。使用 terminationGracePeriodSeconds 延迟到 preStop 并切换它们以查看该过程是否有效。前任。保持 terminationGracePeriodSeconds:30 秒(默认)并将 preStop 命令设置为睡眠 50 秒,并且不应生成消息,因为容器将在那时终止。这按预期工作。
我的问题:
- preStop 挂钩允许(推荐)什么样的进程?因为复制 logs/heapdumps 15 场演出或更多演出将花费大量时间。这个时间将用于定义 terminationGracePeriodSeconds
- 当 preStop 花费的时间超过设置的 gracePeriod 时会发生什么?
(如果日志很大,比如 10 gigs)
- 如果我没有任何挂钩但仍设置了 terminationGracePeriodSeconds 会怎样?容器会保留到那个宽限期吗?
我找到了这篇与此密切相关但无法跟进的文章 https://github.com/kubernetes/kubernetes/issues/24695
感谢所有意见!!
what kind of processes are allowed(recommended) for a preStop hook? As copying logs/heapdumps of 15 gigs or more will take a lot of time. This time will then be used to define terminationGracePeriodSeconds
这里有任何内容,它更像是一种意见,以及您希望 pods 逗留的方式。另一种选择是让你的 pods 终止并将你的数据存储在某个地方(即 AWS S3、EBS),在那里数据将在 Pod 生命周期之后持续存在,然后使用 Job 之类的东西来清理数据,等等
what happens when preStop takes more time than the set gracePeriod? (in case logs are huge say 10 gigs)
您的 preStop 将无法完成,这可能意味着数据不完整或数据损坏。
what happens if I do not have any hooks but still set terminationGracePeriodSeconds ? will the container remain up until that grace time ?
这解释了顺序:
- 向每个容器中的主进程发送SIGTERM信号,“宽限期”倒计时开始。
- 如果容器没有在宽限期内终止,将发送一个 SIGKILL 信号并通知容器。
基本上我想做的是尝试 pod 生命周期并检查我们是否可以做一些 cleanup/backup 例如在 pod 终止之前复制日志。
我需要什么: 在终止
之前将 logs/heapdumps 从容器复制到 hostPath/S3我尝试了什么:
我使用带有 bash 命令的 preStop 挂钩来回显一条消息(只是为了看看它是否有效!!)。使用 terminationGracePeriodSeconds 延迟到 preStop 并切换它们以查看该过程是否有效。前任。保持 terminationGracePeriodSeconds:30 秒(默认)并将 preStop 命令设置为睡眠 50 秒,并且不应生成消息,因为容器将在那时终止。这按预期工作。
我的问题:
- preStop 挂钩允许(推荐)什么样的进程?因为复制 logs/heapdumps 15 场演出或更多演出将花费大量时间。这个时间将用于定义 terminationGracePeriodSeconds
- 当 preStop 花费的时间超过设置的 gracePeriod 时会发生什么? (如果日志很大,比如 10 gigs)
- 如果我没有任何挂钩但仍设置了 terminationGracePeriodSeconds 会怎样?容器会保留到那个宽限期吗?
我找到了这篇与此密切相关但无法跟进的文章 https://github.com/kubernetes/kubernetes/issues/24695
感谢所有意见!!
what kind of processes are allowed(recommended) for a preStop hook? As copying logs/heapdumps of 15 gigs or more will take a lot of time. This time will then be used to define terminationGracePeriodSeconds
这里有任何内容,它更像是一种意见,以及您希望 pods 逗留的方式。另一种选择是让你的 pods 终止并将你的数据存储在某个地方(即 AWS S3、EBS),在那里数据将在 Pod 生命周期之后持续存在,然后使用 Job 之类的东西来清理数据,等等
what happens when preStop takes more time than the set gracePeriod? (in case logs are huge say 10 gigs)
您的 preStop 将无法完成,这可能意味着数据不完整或数据损坏。
what happens if I do not have any hooks but still set terminationGracePeriodSeconds ? will the container remain up until that grace time ?
这解释了顺序:
- 向每个容器中的主进程发送SIGTERM信号,“宽限期”倒计时开始。
- 如果容器没有在宽限期内终止,将发送一个 SIGKILL 信号并通知容器。