<p>When I try to copy some files in an existing directory with a wildcard, I receive the error:</p>

<pre><code>kubectl cp localdir/* my-namespace/my-pod:/remote-dir/
error: one of src or dest must be a remote file specification
</code></pre>

<p>It looks like wildcards support have been removed but I have many files to copy and my remote dir is not empty so I can't use the recursive.</p>

<p>How can I run a similar operation?</p>

<p>Here is what I have come up with:</p>
<pre><code>kubectl exec -n &lt;namespace&gt; &lt;pod_name&gt; -- mkdir -p &lt;dest_dir&gt; \
&amp;&amp; tar cf - -C &lt;src_dir&gt; . | kubectl exec -i -n &lt;namespace&gt; &lt;pod_name&gt; -- tar xf - -C &lt;dest_dir&gt;
</code></pre>
<p>Notice there are two parts, first is making sure the destination directory exists.
Second is using tar to archive the files, send it and unpack it in a container.</p>
<p>Remember, that in order for this to work, it is required that the <code>tar</code> and <code>mkdir</code> binaries are present in your container.</p>
<p>The advantage od this solution over the one proposed earlier (the one with xargs) is that it is faster because it sends all files at once, and not one by one.</p>
