<p>I'm trying to get all the secrets in the cluster of type <code>helm.sh/release.v1</code>:</p>
<pre><code>$ curl -X GET $APISERVER/api/v1/secrets --header &quot;Authorization: Bearer $TOKEN&quot; --insecure
{
  &quot;kind&quot;: &quot;SecretList&quot;,
  &quot;apiVersion&quot;: &quot;v1&quot;,
  &quot;metadata&quot;: {
    &quot;selfLink&quot;: &quot;/api/v1/secrets&quot;,
    &quot;resourceVersion&quot;: &quot;442181&quot;
  },
  &quot;items&quot;: [
    {
      &quot;metadata&quot;: {
         ...
      },
      &quot;data&quot;: {
         ...
      },
      &quot;type&quot;: &quot;helm.sh/release.v1&quot;
    },
    {
      &quot;metadata&quot;: {
         ...
      },
      &quot;data&quot;: {
         ...
      },
      &quot;type&quot;: &quot;kubernetes.io/service-account-token&quot;
    },
    {
      &quot;metadata&quot;: {
         ...
      },
      &quot;data&quot;: {
         ...
      },
      &quot;type&quot;: &quot;kubernetes.io/service-account-token&quot;
    },
    ...
}
</code></pre>
<p>I can use the command above and then filter by myself (<code>jq</code> or whatever) but I wonder if there's an option to filter in the API by adding query parameters or something, for example (didn't work):</p>
<pre><code>curl -X GET $APISERVER/api/v1/secrets?type=&lt;value&gt;
</code></pre>
<p>any idea how to filter by specific field? (<code>type</code>) can I also request specific fields in the response (if I don't care about the <code>data</code> for instance)?</p>

ItayB
<blockquote>
<p>I'm going to use HTTP requests from my application (python) that runs
within a pod in the cluster. I am trying to be more efficient and ask
only for what I need (only specific type and not all secrets in the
cluster)</p>
</blockquote>
<p>If your application is written in <strong>Python</strong>, maybe it's a good idea to use <a href="https://github.com/kubernetes-client/python" rel="nofollow noreferrer">Kubernetes Python Client library</a> to get the secrets ?</p>
<p>If you want to get all the secrets in the cluster of type <code>helm.sh/release.v1</code>, you can do it with the following <strong>Python</strong> code:</p>
<pre><code>from  kubernetes import client , config 

config.load_kube_config()
v1 = client.CoreV1Api()
list_secrets = v1.list_secret_for_all_namespaces(field_selector='type=helm.sh/release.v1')
</code></pre>
<p>If you also want to count them, use:</p>
<pre><code>print(len(list_secrets.items))
</code></pre>
<p>to print secret's name use:</p>
<pre><code>print(list_secrets.items[0].metadata.name)
</code></pre>
<p>to retrieve it's data:</p>
<pre><code>print(list_secrets.items[0].data)
</code></pre>
<p>and so on...</p>
<p>More details, including arguments that can be used with this method, you can find <a href="https://raw.githubusercontent.com/kubernetes-client/python/master/kubernetes/docs/CoreV1Api.md" rel="nofollow noreferrer">here</a> (just search for <code>list_secret_for_all_namespaces</code>):</p>
<pre><code># **list_secret_for_all_namespaces**
&gt; V1SecretList list_secret_for_all_namespaces(allow_watch_bookmarks=allow_watch_bookmarks, _continue=_continue, field_selector=field_selector, label_selector=label_selector, limit=limit, pretty=pretty, resource_version=resource_version, timeout_seconds=timeout_seconds, watch=watch)
</code></pre>
