<p>I'm a very new user of k8s python client.</p>

<p>I'm trying to find the way to get jobs with regex in python client.</p>

<p>For example in CLI,</p>

<p><code>kubectl describe jobs -n mynamespace partial-name-of-job</code></p>

<p>gives me the number of jobs whose name has <code>partial-name-of-job</code> in "mynamespace".</p>

<p>I'm trying to find the exact same code in python client.</p>

<p>I did several searches and some are suggested to use label selector, but the python client API function <code>BatchV1Api().read_namespaced_job()</code> requires the exact name of jobs.</p>

<p>Please let me know if there's a way!</p>

<p>Unfortunately, <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/BatchV1Api.md#read_namespaced_job" rel="nofollow noreferrer">read_namespaced_job</a> doesn't allow to filter jobs with name pattern.</p>

<p>There is <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/BatchV1Api.md#list_namespaced_job" rel="nofollow noreferrer">list_namespaced_job</a> that have <code>field_selector</code> argument.  But <code>field_selector</code> supports a limited list of operators:</p>

<blockquote>
  <p>You can use the =, ==, and != operators with field selectors (= and == mean the same thing). </p>
</blockquote>

<p>So, if you want to apply regex filter to job list, I'd suggest to get full list and then filter it using <a href="https://docs.python.org/3/howto/regex.html" rel="nofollow noreferrer">Python regex</a></p>
