<p>I was looking for a solution but I couldn't find any.</p>
<p>I have a bash script which executes something like this:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl get services -o=json | \
jq '.items[].metadata.annotations | '\
   'select (.&quot;my-ingress/enabled&quot; == &quot;true&quot;) | '\
   '{&quot;my-ingress/path&quot;, &quot;my-ingress/service-name&quot;, &quot;my-ingress/service-port&quot;}'
</code></pre>
<p>Which means it can take list of the services, filter and take only with annotations <code>my-ingress/enabled == true</code></p>
<p>Based on that result it creates dynamically YAML for Ingress and loads it.</p>
<p>Everywhere I was looking, Helm is using templates and other fancy approaches but nowhere I could find any information how to ask K8S about some resources and based on that info build YAML.</p>
<p>Is this possible at all?</p>
<p><strong><em>Note</em></strong>: calling Bash to prepare some kind <code>values.yaml</code> is not an option in my case.</p>

WBAR
<p>You may use <a href="https://helm.sh/docs/chart_template_guide/functions_and_pipelines/#using-the-lookup-function" rel="nofollow noreferrer">HELM's lookup function</a> to query the cluster</p>
<blockquote>
<p>The lookup function can be used to look up resources in a running
cluster. The synopsis of the lookup function is lookup apiVersion,
kind, namespace, name -&gt; resource or resource list.</p>
<p>parameter type apiVersion string kind string namespace    string
name  string Both name and namespace are optional and can be passed as
an empty string (&quot;&quot;).</p>
</blockquote>
<pre><code>{{ range $index, $service := (lookup &quot;v1&quot; &quot;Service&quot; &quot;mynamespace&quot; &quot;&quot;).items }}
    {{/* do something with each service */}}
{{ end }}
</code></pre>
<p><strong>Important note:</strong></p>
<blockquote>
<p>Keep in mind that Helm is not supposed to contact the Kubernetes API Server during a <code>helm template</code> or a <code>helm install|update|delete|rollback --dry-run</code>, so the lookup function will return an empty list (i.e. dict) in such a case.</p>
</blockquote>
