<p>I'm exploring an easy way to read K8S resources in the Argo workflow. The current documentation is focusing mainly on create/patch with conditions (<a href="https://argoproj.github.io/argo/examples/#kubernetes-resources" rel="nofollow noreferrer">https://argoproj.github.io/argo/examples/#kubernetes-resources</a>), while I'm curious if it's possible to perform &quot;action: get&quot;, extra part of the resource state (or full resource) and pass it downstream as artifact or result output. Any ideas?</p>

<p><code>action: get</code> is not a feature available from Argo.</p>
<p>However, it's easy to use <code>kubectl</code> from within a Pod and then send the JSON output to an output parameter. This uses a BASH script to send the JSON to the <code>result</code> output parameter, but an explicit output parameter or an output artifact are also viable options.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: kubectl-bash-
spec:
  entrypoint: kubectl-example
  templates:
  - name: kubectl-example
    steps:
    - - name: generate
        template: get-workflows
    - - name: print
        template: print-message
        arguments:
          parameters:
          - name: message
            value: &quot;{{steps.generate.outputs.result}}&quot;
  - name: get-workflows
    script:
      image: bitnami/kubectl:latest
      command: [bash]
      source: |
        some_workflow=$(kubectl get workflows -n argo | sed -n 2p | awk '{print $1;}')
        kubectl get workflow &quot;$some_workflow&quot; -ojson
  - name: print-message
    inputs:
      parameters:
      - name: message
    container:
      image: alpine:latest
      command: [sh, -c]
      args: [&quot;echo result was: '{{inputs.parameters.message}}'&quot;]
</code></pre>
<p>Keep in mind that <code>kubectl</code> will run with the permissions of the Workflow's ServiceAccount. Be sure to <a href="https://github.com/argoproj/argo/blob/master/docs/service-accounts.md" rel="nofollow noreferrer">submit the Workflow using a ServiceAccount</a> which has access to the resource you want to get.</p>
