How does the copy artifacts job work in Kubernetes

11/27/2018

I am trying to run a hyperledger fabric blockchain network on kubernetes using https://github.com/IBM/blockchain-network-on-kubernetes as the reference. In one of the steps, the atrifacts (chaincode, configtx.yaml ) are copied into the volume using the below yaml file

https://github.com/IBM/blockchain-network-on-kubernetes/blob/master/configFiles/copyArtifactsJob.yaml

I am unable to understand how the files are copied into the shared persistent volume. Does the entry point command on line 24 copy the artifaces to the persistent volume? I do not see cp here. So how does the copy happen?

 command: ["sh", "-c", "ls -l /shared; rm -rf /shared/*; ls -l /shared; while [ ! -d /shared/artifacts ]; do echo Waiting for artifacts to be copied; sleep 2; done; sleep 10; ls -l /shared/artifacts; "]
-- ilegolas
hyperledger-fabric
kubernetes

1 Answer

11/27/2018

Actually this job does not copy anything. It is just used to wait until copy complete.

Look at setup_blockchainNetwork.sh script. Actual copy is happening at line 82.

kubectl cp ./artifacts $pod:/shared/

This line copy content of ./artifact into the /shared directory of shared-pvc volume.

The job just make sure that copy is completed before processing further task. When copy is done, the job will find the files in /shared/artifacts directory and will go to completion. When the job is completed, the script proceed to further task. Look at the condition here.

-- Emruz Hossain
Source: StackOverflow