How to copy files from kubernetes Pods to local system

后端 未结 10 1613
暖寄归人
暖寄归人 2020-12-24 10:22

I\'m trying to copy files from Kubernetes Pods to my local system. I am getting the below error while running following command:

kubectl cp aks-ssh2-6cd4948         


        
10条回答
  •  庸人自扰
    2020-12-24 11:16

    If anyone uses windows pods, it may be hard to get files copied to the pods from local machine with those linux paths for kubectl cp command:

    Procedure to copy files from local machine to kubernetes pod: (especially windows container)

    1. I want to copy node.aspx from my local machine to podname:\c:\inetpub\wwwroot
    2. First upload Node.aspx to your cloud drive, path will be /home/{your_username} in my case /home/pranesh
    3. Then find out the pod name, in my case its aspx-deployment-84597d88f5-pk5nh, follow below command
    PS /home/pranesh> kubectl cp /home/pranesh/Node.aspx aspx-deployment-84597d88f5-pk5nh:/Node.aspx
    
    1. This copies the file to c drive of container,
    2. then move file from c drive to required path with powershell
    PS /home/pranesh> kubectl exec aspx-deployment-84597d88f5-pk5nh powershell "Copy-Item "C:\Node.aspx" -Destination "C:\inetpub\wwwroot""
    
    1. Use the reverse procedure for copying from container to cloud drive and download.

提交回复
热议问题