Tekton:如何删除成功的管道?
我急剧的Tekton Usecase很简单:
- X天失败后,应删除成功的管道弹药,
- 因此不应自动删除Pipelineruns。
我计划在最初的清理任务中进行清理。在我看来,这比注释或cronjob诉求更好。只要没有任何新的建造,就无需删除。
直接方法:
- 失败:
TKN DELETE
似乎并没有很有帮助,因为它不会区分成功与否。 - 失败:
oc delete-field-selector ...
不包含隐藏良好但高度表达的字段状态。条件[0] .type ====成功的
间接方法(首先过滤podnames的列表,然后删除它们 - 根本不是优雅):
- 失败 :用
-O = JSONPATH过滤输出...
似乎代价高昂,条件 - 阵列似乎打破了声明,所以(为什么曾经呢?!)一切都返回... - 我的最后一次尝试是
tkn Pipelineruns列表-Show-show maregand-fields
和用sed/awk来解析这一点……这很粗糙……但是至少它可以做我想做的事情……而且非常有效。但是,当输出的设计将在未来的版本中变化时,可能会导致脆弱...
您有更好的优雅方法吗? 多谢!
My aspired tekton usecase is simple:
- successful pipelineruns should be removed after x days
- failed pipelineruns shouldn't be removed automatically.
I plan to do the cleanup in an initial cleanup-task. That seems better to me than annotation- or cronjob-approaches. As long as nothing new is built, nothing has to be deleted.
Direct approaches:
- Failed:
tkn delete
doesn't seem very helpful because it doesn't discriminate between successful or not. - Failed:
oc delete --field-selector ...
doesn't contain the well hidden but highly expressive fieldstatus.conditions[0].type==Succeeded
Indirect approaches (first filtering a list of podnames and then delete them - not elegant at all):
- Failed: Filtering output with
-o=jsonpath...
seems costly and the condition-array seems to break the statement, so that (why ever?!) everything is returned... not viable - My last attempt is
tkn pipelineruns list --show-managed-fields
and parse this with sed/awk... which is gross... but at least it does what I want it to do... and quite efficiently at that. But it might result as brittle when the design of the output is going to change in future releases...
Do you have any better more elegant approaches?
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在有更好的解决方案之前,我将发布我当前的解决方案(及其缺点):
我们的清理任务现在围绕以下解决方案构建,评估由
tkn Pipelineruns list列表
>:优势:
缺点:
总而言之,我希望该解决方案能够保留,直到有更多有用的客户端功能使所需信息可以直接过滤。实际上,我希望
tkn Pipelineruns删除 - State成功-Period P1D
。该时间段的符号来自ISO8601。
Until a better solution is there, I'll post my current solution (and its drawbacks):
Our cleanup-task is now built around the following solution, evaluating the table returned by
tkn pipelineruns list
:Advantages:
Disadvantages:
All in all I hope the solution will hold until there are some more helpful client-features that make the desired info directly filterable. Actually I'd hope for something like
tkn pipelineruns delete --state successful --period P1D
.The notation for the time period is from ISO8601.
为了完整,我在这里粘贴了kubectl/oc本机命令,为我们这些没有TKN CLI的人。根据需要替换
target-namespace
。删除失败的管道:
删除成功的Pipelineruns:
For completeness, I paste here the kubectl/oc native command for those of us who do not have the tkn cli. Replace
target-namespace
as needed.Delete failed pipelineruns:
Delete successful pipelineruns: