kubernetesazure-container-service

Copying files to/from Windows container on a k8s cluster


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?


Solution

  • 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.