<p>Trying to copy and execute a bash script in a POD (which has one container)</p>

<p>kubectl cp ../docker/scripts/upload_javadumps.sh  ${POD}:/opt -n apm</p>

<p>This commands works perfectly, But we have multiple Namespaces, Hence I wanted to use --all-namespaces like shown below 
 which errors out saying, Error: unknown flag: --all-namespaces</p>

<p>How Do I use --all-namspaces in kubectl cp command?</p>

<pre><code>
kubectl cp ../docker/scripts/upload_javadumps.sh  ${POD}:/opt --all-namespaces
echo "Successfully copied the upload_javadumps.sh script"```

</code></pre>

Suresh Ravi
<p>For <code>kubectl cp</code> flag <code>--all-namespaces</code> doesn't exist, you can check it with <code>kubectl cp -h</code>.</p>

<p>In your case I would go with simple bash loop like this:</p>

<pre><code>for ns in namespace1 namespace2; do kubectl cp ../docker/scripts/upload_javadumps.sh ${POD}:/opt -n $ns;done
</code></pre>
