gpt4 book ai didi

跨命名空间的 Kubernetes Cronjob

转载 作者:行者123 更新时间:2023-12-02 11:38:42 29 4
gpt4 key购买 nike

我有一个 Kubernetes 集群,其中相同的应用程序运行了几次但具有不同的命名空间。想象

ns=app1 name=app1
ns=app2 name=app2
ns=app3 name=app3
[...]
ns=app99 name=app99
现在我需要在所有这些 Pod 中每 10 分钟执行一次 cronjob。
路径每次都一样。
有没有“最好的方法”来实现这一目标?
我在想一个以“CronJob”形式运行的 kubectl 图像,如下所示:
kubectl get pods -A -o=custom-columns='DATA:spec.containers[?(@.image=="registry.local/app-v1")].image' | xargs -i kubectl exec {} /usr/bin/scrub.sh
但我很确定这不是解决这个问题的正确方法。

最佳答案

正如我和@Argha Sadhu 所提到的,其中一种选择是为所有 Pod 创建 cronjobs,但它会每 10 分钟生成 100 个 Pod,所以正如 @LucidEx 提到的那样,在云中存储可以,但不是这样在他的环境中。

Concerning the storage it would be fine if it was some storage in a cloud I don't have to care about, but since it's a shared ceph storage with all it's overheads (especially ram and cpu) when you claim a volume and the need to have them zero'd on delete creating/deleting 100 storage claims every 10 minutes just isn't viable in my environment. – LucidEx



另一个选项可以在这个较旧的 stackoverflow question 中找到。 ,这里问了类似的问题。
正如@LucidEx 提到的

I'll probably roll with a bash loop/routine instead of that python code snippet but will go with that approach.


这个python代码片段是 here .

关于跨命名空间的 Kubernetes Cronjob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63029349/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com