clusterpedia icon indicating copy to clipboard operation
clusterpedia copied to clipboard

support list field filtering

Open scydas opened this issue 3 years ago • 3 comments

support list field filtering

kubectl get po --field-selector="spec.containers[].name!=container1"

kubectl get po --field-selector="spec.containers[].name == container1"

kubectl get po --field-selector="spec.containers[1].name in (container1,container2)"

PostgreSQL

SELECT *
FROM "resources",
     jsonb_array_elements(object -> 'status' -> 'conditions') as obj
WHERE "group" = 'apps'
  AND "resource" = 'deployments'
  AND "version" = 'v1'
  AND obj ->> 'status' = 'True'
ORDER BY namespace, name
LIMIT 10;

MySQL

SELECT *
FROM resources
WHERE `group` = 'apps'
  AND resource = 'deployments'
  AND version = 'v1'
  AND json_contains(object, '{"status": "True"}', '$.status.conditions')
ORDER BY namespace, name
LIMIT 10;

scydas avatar Jan 11 '22 08:01 scydas

@scydas Thanks for your work. The sql statements in postgres can seriously break sql generation, we can see if others have a need for this feature.

Iceber avatar Jan 12 '22 02:01 Iceber

hi! I think this is a very necessary feature, in a multi-cluster environment, there are bound to be a lot of pods, and if there is a problem with the service and I need to check the status of the pods. I need this feature to retrieve the unhealthy pods, but pod.stauts.conditions is an array, so I can't do it. Only search by myself 😣.

`status: conditions:

  • lastProbeTime: null lastTransitionTime: "2022-01-17T12:08:20Z" status: "True" type: Initialized
  • lastProbeTime: null lastTransitionTime: "2022-01-17T12:14:44Z" status: "True" type: Ready
  • lastProbeTime: null lastTransitionTime: "2022-01-17T12:14:44Z" status: "True" type: ContainersReady
  • lastProbeTime: null lastTransitionTime: "2022-01-17T12:08:20Z" status: "True" type: PodScheduled`

feeltimeQ avatar Mar 11 '22 10:03 feeltimeQ

For mysql, array fields can be filtered using raw sql. For pg, we may add a fromSQL query parameter in the future to override the pg syntax

Iceber avatar Jul 13 '22 03:07 Iceber