1

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!

  • try replacing `/usr/local/myproject/tomcat/webapps/WEB-INF/lib` with `/tmp` and check if its working ? – P.... Aug 29 '22 at 13:14
  • No, the same message – Mikhail Krasikov Aug 29 '22 at 13:25
  • Your command is right, not reproducible on kubernetes 1.24.3 and Linux client. – P.... Aug 29 '22 at 13:37
  • Would it make more sense to create a custom Docker image that already contains Tomcat and your application jar file? Right now you'd have to repeat this `kubectl cp` command for every replica of your deployment, and repeat it again if the pods are ever destroyed and recreated (including if a node fails outside your control or if a node has excessive resource utilization). – David Maze Aug 29 '22 at 14:19

1 Answers1

0

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
  • Yes, it helped, thank you! To tell the truth, the command also works with C:/ on some machines, if you encounter this, see the solution above – Mikhail Krasikov Oct 18 '22 at 12:59