在部署 Kubernetes 应用程序时,我想检查是否存在特定的 PodSecurityPolicy,如果存在,则跳过再次安装。我遇到了helm 查找功能,它允许我们检查现有的 K8 资源。虽然我了解如何使用此函数获取所有同类资源,但如何使用此函数检查名为“myPodSecurityPolicy”的 PodSecurityPolicy 是否存在。
我试过这样的事情:
{{- if ne (lookup "v1" "PodSecurityPolicy" "" "") "myPodSecurityPolicy"}}
<do my stuff>
{{- end }}
Run Code Online (Sandbox Code Playgroud)
但看起来我不能这样比较,看到一个错误 -
error calling ne: invalid type for comparison
Run Code Online (Sandbox Code Playgroud)
任何输入?提前致谢。
我发现如果升级后的 helm hook 失败,它会重试 5 次然后放弃。如何确保钩子只尝试一次成功并在失败时放弃?或者我可以让 helm hook 仅在失败时在特定条件下重试,而不是总是重试?我在这里找不到此用例的任何文档/参数。