gpt4 book ai didi

kubernetes - Kubectl JSONPath表达式基于当前上下文获取cluster.server属性

转载 作者:行者123 更新时间:2023-12-02 12:02:52 28 4
gpt4 key购买 nike

我想只使用jsonpath的kubectl来获取当前的集群地址。我已经尝试了以下方法,以及它的许多排列方式,但这似乎不起作用。

kubectl config view -o jsonpath='{.clusters[?($.current-context)].cluster.server}'

是否可以仅使用jsonpath?

最佳答案

您可以使用--minify标志:

--minify=false: Remove all information not used by current-context from the output



然后从当前上下文输出中过滤 server字段:
kubectl config view --minify -o jsonpath='{.clusters[].cluster.server}'

关于kubernetes - Kubectl JSONPath表达式基于当前上下文获取cluster.server属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58541209/

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