2

I'm trying to copy files to/from a Windows container in a pod running on an ACS k8s cluster.

I'm using this kubectl command from my Windows 10 laptop:

kubectl cp dev-acs-conn-testdn-1981314364-rjc0l:\app\nettrace.etl c:\

And I'm getting this error in response:

error: archive/tar: invalid tar header

I've tried this from clusters running both v1.7.7 and v1.7.9 of k8s as well as Server 2016 ltsc and Server v1709. My kubectl.exe is v1.8.5. I have some valuable debugging files stranded on my container, any idea how I can get this to work?

BrettRobi
  • 3,793
  • 7
  • 40
  • 64

3 Answers3

2

So it turns out that the "kubectl cp" command requires that tar be in the container, not on the local system as I expected. And since Windows doesn't ship with tar.exe the problem lies there.

I deployed a new pod that included a Windows version of tar.exe and it's dependencies. This got me further in a Server 2016 ltsc container. I simply had to adjust my syntax slightly and the below worked:

kubectl cp dev-acs-conn-testdn-1981314364-rjc0l:/app/nettrace.etl nettrace.etl

However, this same process does NOT work on a Server v1709 container. When I try exactly the same process I get this error:

tar: Cannot open -: Permission denied

tar: Error is not recoverable: exiting now

Clearly a permissions error, but I have no idea what permissions are the issue and how to change them. Any ideas?

Community
  • 1
  • 1
BrettRobi
  • 3,793
  • 7
  • 40
  • 64
1

kubectl cp "filename" : -c -n

Move to current directory where is present and run above command with correct value.

Example :

kubectl cp "file_for_web-service.html" web-service-74fccf-x4d:C:\abc.html -c web-service -n dev

0

Circling back on this issue. Now that Windows v1803 containers are functional in kubernetes I have tested this same issue and all is working correctly. v1803 of Windows started shipping with tar.exe as part of the operating system. Yay for Microsoft!

One oddity is that when copying FROM the pod TO your local system, the destination is always a folder. It uncompresses any files from the source to that folder, but if you specify a single file it still creates a folder of that name. No biggie, just odd.

So to me the answer to this questions is: Use v1803 container images. Yeah this may not be what you want to hear but the reality is that Windows container support is still somewhat nascent, and kubernetes support is very much nascent as of v1803. v1809 may be where it finally becomes solid and reliable.

BrettRobi
  • 3,793
  • 7
  • 40
  • 64