Can I use regular expression for job name in kubernetes python client? Can I use regular expression for job name in kubernetes python client? kubernetes kubernetes

Can I use regular expression for job name in kubernetes python client?


Unfortunately, read_namespaced_job doesn't allow to filter jobs with name pattern.

There is list_namespaced_job that have field_selector argument. But field_selector supports a limited list of operators:

You can use the =, ==, and != operators with field selectors (= and == mean the same thing).

So, if you want to apply regex filter to job list, I'd suggest to get full list and then filter it using Python regex


kubectl describe jobs (it describes all jobs in default namespace) instead of returning the number of jobs.

So as mentioned by Yasen please use list_namespaced_job with namespace parameter it gives api request like kubectl get --raw=/apis/batch/v1/namespaces/{namespace}/jobs

You can also modify your script and get some specific value. Please run kubectl get or describe --v=8 to get the strict api request. Please refer to Kubectl output verbosity and debugging

Hope this help