如何在kubectl go模板中使用{{if StartsWith str1 str2}}?

我正在使用kubectl来获取容器状态,在那里我只知道应该部署的image标签的开始。有什么方法可以做到这一点?

我尝试使用slice和StartsWith,但kubectl go-template似乎都不支持。

我相信,如果支持StartsWith,这应该可以工作:

kubectl get pods --all-namespaces -o 'go-template={{range .items}}{{$status := .status}}{{range .spec.containers}}{{if StartsWith .image '"\"$DEPLOY_IMAGE\""'}}{{$status.phase}}{{end}}{{end}}{{end}}'

我期望某种输出,但是我得到的是: template: output:1: function "StartsWith" not defined

maya_smily 回答:如何在kubectl go模板中使用{{if StartsWith str1 str2}}?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3121854.html

大家都在问