Search code examples
kubernetessdkcloudkubectl

How to copy file from local system to kubernetes pods with new kubectl version


I'm trying to copy files from my local to kubernetes pods. I've been using the command for a very few months now and everything worked fine:

kubectl cp C:/test.jar backend-0:/usr/local/myproject/tomcat/webapps/WEB-INF/lib -c tomcat

Now I bought a new computer, re-configured the development environment, and now when I try to use the same command, I see an error:

error: one of src or dest must be a local file specification

I'm using Google Cloud SDK as a terminal. The old computer had the Google Cloud SDK version 368.0.0, now it's 396.0.0. Also, kubectl version changed, was 1.16.6 now it's 1.22.12.

Please tell me which command in the terminal will be relevant now, how should I use copying? Thanks!


Solution

  • You cannot use absolute paths like C:/test.jar

    You can try the following:

    1. Make sure you are under c:/
    2. Execute:
      kubectl cp test.jar backend-0:/usr/local/myproject/tomcat/webapps/WEB-INF/lib -c tomcat