HiveBrain v1.2.0
Get Started
← Back to all entries
patternkubernetesModerate

Copy multiple files using * wildcard from kubernetes container

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
wildcardcontainerkubernetesfilesusingmultiplefromcopy

Problem

I have several files named out1, out2, ... in my Kubernetes container. I want to copy them to my local computer. I am using:

$ kubectl cp pod:/path/out* .


But I am getting an error:


tar: Removing leading /' from member names

tar: /path/out*: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors

error: path/out* no such file or directory

How can I use
kubectl cp` with wildcards?

Solution

Wildcard support was added to kubectl cp in the #72641 pull request.

It is merged but only available in Kubernetes v1.14.0. Take a look at the ChangeLog:

Notable Features:

[...]

• kubectl supports copying files with wild card
(#72641, @dixudx)

However, as stated on the issue #78854 the PR was made without proper tests and the feature is actually broken. The PR to fix the problem (#78928) is open since June, and it's not merged yet.

Although the PR to fix the feature exists, they are also considering removing the support to wildcard copy.

Context

StackExchange DevOps Q#6669, answer score: 13

Revisions (0)

No revisions yet.