<p>I'm using GCP composer to run an algorithm and at the end of the stream I want to run a task that will perform several operations copying and deleting files and folders from a volume to a bucket I'm trying to perform these copying and deleting operations via a <code>kubernetespodoperator</code>. I'm having hardship finding the right way to run several commands using &quot;cmds&quot; I also tried using &quot;cmds&quot; with &quot;arguments&quot;.
Here is my <code>KubernetesPodOperator</code> and the cmds and arguments combinations I tried:</p>
<pre><code>post_algo_run = kubernetes_pod_operator.KubernetesPodOperator(
    task_id=&quot;multi-coher-post-operations&quot;,
    name=&quot;multi-coher-post-operations&quot;,
    namespace=&quot;default&quot;,
    image=&quot;google/cloud-sdk:alpine&quot;,
    
    ### doesn't work ###
    cmds=[&quot;gsutil&quot;, &quot;cp&quot;, &quot;/data/splitter-output\*.csv&quot;,  &quot;gs://my_bucket/data&quot; , &quot;&amp;&quot; , &quot;gsutil&quot;, &quot;rm&quot;, &quot;-r&quot;, &quot;/input&quot;], 
    #Error:
        #[2022-01-27 09:31:38,407] {pod_manager.py:197} INFO - CommandException: Destination URL must name a directory, bucket, or bucket
        #[2022-01-27 09:31:38,408] {pod_manager.py:197} INFO - subdirectory for the multiple source form of the cp command.
    ####################

    ### doesn't work ###
    # cmds=[&quot;gsutil&quot;, &quot;cp&quot;, &quot;/data/splitter-output\*.csv&quot;,  &quot;gs://my_bucket/data ;&quot;,&quot;gsutil&quot;, &quot;rm&quot;, &quot;-r&quot;, &quot;/input&quot;],
        # [2022-01-27 09:34:06,865] {pod_manager.py:197} INFO - CommandException: Destination URL must name a directory, bucket, or bucket
        # [2022-01-27 09:34:06,866] {pod_manager.py:197} INFO - subdirectory for the multiple source form of the cp command.
    ####################

    ### only preform the first command - only copying ###
    # cmds=[&quot;bash&quot;, &quot;-cx&quot;],
    # arguments=[&quot;gsutil cp /data/splitter-output\*.csv gs://my_bucket/data&quot;,&quot;gsutil rm -r /input&quot;],                                    
        # [2022-01-27 09:36:09,164] {pod_manager.py:197} INFO - + gsutil cp '/data/splitter-output*.csv' gs://my_bucket/data
        # [2022-01-27 09:36:11,200] {pod_manager.py:197} INFO - Copying file:///data/splitter-output\Coherence Results-26-Jan-2022-1025Part1.csv [Content-Type=text/csv]...
        # [2022-01-27 09:36:11,300] {pod_manager.py:197} INFO - / [0 files][    0.0 B/ 93.0 KiB]                                                
        # / [1 files][ 93.0 KiB/ 93.0 KiB]
        # [2022-01-27 09:36:11,302] {pod_manager.py:197} INFO - Operation completed over 1 objects/93.0 KiB.
        # [20   22-01-27 09:36:12,317] {kubernetes_pod.py:459} INFO - Deleting pod: multi-coher-post-operations.d66b4c91c9024bd289171c4d3ce35fdd
    ####################


    volumes=[
        Volume(
            name=&quot;nfs-pvc&quot;,
            configs={
                &quot;persistentVolumeClaim&quot;: {&quot;claimName&quot;: &quot;nfs-pvc&quot;}
            },
        )
    ],
    volume_mounts=[
        VolumeMount(
            name=&quot;nfs-pvc&quot;,
            mount_path=&quot;/data/&quot;,
            sub_path=None,
            read_only=False,
        )
    ],
)
</code></pre>

<p>I found a technic for running multiple commands.
First I found the relations between Kubernetespodoperator cmds and arguments properties to Docker's ENTRYPOINT and CMD.</p>
<p>Kubernetespodoperator cmds overwrite the docker original ENTRYPOINT
and Kubernetespodoperator arguments is equivalent to docker's CMD.</p>
<p>And so in order to run multiple commands from the Kubernetespodoperator I've used the following syntax:
I've set the Kubernetespodoperator cmds to run bash with -c:</p>
<pre><code>cmds=[&quot;/bin/bash&quot;, &quot;-c&quot;],
</code></pre>
<p>And I've set the Kubernetespodoperator arguments to run two echo commands separated by &amp;:</p>
<pre><code>arguments=[&quot;echo hello &amp;&amp; echo goodbye&quot;],
</code></pre>
<p>So my Kubernetespodoperator looks like so:</p>
<pre><code>stajoverflow_test = KubernetesPodOperator(
    task_id=&quot;stajoverflow_test&quot;,
    name=&quot;stajoverflow_test&quot;,
    namespace=&quot;default&quot;,
    image=&quot;google/cloud-sdk:alpine&quot;,
    cmds=[&quot;/bin/bash&quot;, &quot;-c&quot;],
    arguments=[&quot;echo hello &amp;&amp; echo goodbye&quot;],
)
</code></pre>
