前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【Kubernetes】自定义资源CRDs不支持fieldselector

【Kubernetes】自定义资源CRDs不支持fieldselector

作者头像
runzhliu
发布2020-09-18 10:19:44
1.8K0
发布2020-09-18 10:19:44
举报
文章被收录于专栏:容器计算容器计算

按照对 Pod 的认识,我们可以通过 field-selector 来找到我们需要的状态的 Pod,但是当我们通过同样的方法去找需要的 CRDs 的时候,比如 sparkapp,会发现报错。

代码语言:javascript
复制
# kubectl get pod -n allblue --field-selector status.phase=Running
NAME                                              READY   STATUS    RESTARTS   AGE
allblue-service-2556-4626-test-6874f68b6f-btxvv   1/1     Running   0          19d
allblue-service-2556-4626-test-6874f68b6f-lt6lj   1/1     Running   0          19d
allblue-service-2556-4627-test-6fb6f755d4-sjfts   1/1     Running   0          19d
allblue-service-2556-4627-test-6fb6f755d4-wps74   1/1     Running   0          19d
allblue-service-2556-4672-test-cf6994f54-cjr92    1/1     Running   0          7d8h
# kubectl get sparkapp -n allblue --field-selector .status.applicationState.state=Running
Error from server (BadRequest): Unable to find "sparkoperator.k8s.io/v1beta2, Resource=sparkapplications" that match label selector "", field selector ".status.applicationState.state=Running": field label not supported: .status.applicationState.state

简单 Google 了一下,找到 Unable to use a fieldSelector with custom resources #51046,按照这个 issue 的说法,CRDs 还不支持除了 name 和 namespace 以外的 filed selector。不过依然可以通过 kubectl 和 shell 的结合来搞一下。

代码语言:javascript
复制
kubectl get pg -n log -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.phase}{"\n"}{end}' | grep -i Finished|awk '{print $1}'|xargs kubectl delete pg -n log
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-09-16 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档