Search code examples
kubernetesazure-devopskubectlazure-aksazure-cli

How to copy or moves files from one directory to another directory inside the Kubernetes POD (Azure Devops release Pipeline)


I would like to move files that are available in the system working directory in the azure pipeline to the Kubernetes pod.

  1. Method one (Kubectl cp command)

    kubectl cp D:\a\r1\a\test-files\westus\test.txt /test-745f6564dd:/inetpub/wwwroot/

D:\a\r1\a\test-files\westus\test.txt -- my system working directory file location

(name-space)/test-745f6564dd:/inetpub/wwwroot/ -- kubernetes pod location

I have tried to use kubectl cp command but facing an error.

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

  1. Method two command line tool in azure devops

Even i tried to use command line to copy files from one directory to another directory.

cd C:\inetpub\wwwroot> 

copy C:\inetpub\wwwroot\west\test.txt C:\inetpub\wwwroot\

Once this task is executed in the azure pipeline, its throwing error.

he syntax of the command is incorrect.

  1. Method three azure cli

I have tried to use azure cli and login into Kubernetes and tried to try one of the below codes. But not throwing any errors even file is not copied too.

az aks get-credentials --resource-group test --name test-dev

cd C:\inetpub\wwwroot

dir

copy C:\inetpub\wwwroot\west\test.txt C:\inetpub\wwwroot\

Is there any way do this operation.


Solution

  • For the first error:

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

    Try to run the kubectl cp command from the same directory where your file is there and instead of giving the whole path try like below:

    kubecto cp test.txt /test-745f6564dd:/inetpub/wwwroot/test.txt