kubectl cp "error: one of src or dest must be a remote file specification"

5/6/2020

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

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

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.

How can I run a similar operation?

-- Vincent J
kubectl
kubernetes

1 Answer

5/6/2020

As a workaround you can use:

find * | xargs -i{} kubectl cp my-namespace/my-pod:/remote-dir/

In find you can use a wildcard to specify files you are looking for and it will copy it to the pod.

-- KFC_
Source: StackOverflow