如何解决jsonpath kubectl中的时间运算符
我为pod设置了使用timetemp格式的标签“ mytime”。现在我要选择所有过期时间的豆荚?有些人这样想:
kubectl get pods -o jsonpath='{range .items[*]}{.metadata.labels.mytime<$now()}{.metadata.name}{ "\n"}{end}'
但是我看到错误
error: error executing jsonpath "{range .items[*]}{.metadata.labels.mytime<$now()}{.metadata.name}{ \"\\n\"}{end}": Error executing template: unrecognized identifier now(). Printing more information for debugging the template:
template was:
{range .items[*]}{.metadata.creationTimestamp>$now()}{.metadata.name}{ "\n"}{end}
object given to jsonpath engine was: ...
如何在时间上使用时间?
解决方法
kubectl -n test get deployment -o jsonpath='{.items[?(@.metadata.labels.mytime<"2020-10-08_14-15-07")].metadata.name}'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。