opscli file Command Usage
The opscli file
command is used for transferring files between the local host, object storage, API servers, and clusters. Below are the details for various use cases.
1. Host - Local and Object Storage File Transfer
- Set AK/SK (Access Key / Secret Key)
export ak=<your-ak>
export sk=<your-sk>
- Upload a Local File to Object Storage
To upload a file ./tmp.log
to the object storage at s3://logs/tmp.log
:
/usr/local/bin/opscli file --direction upload --localfile ./tmp.log --remotefile s3://logs/tmp.log --bucket obs-test
Here:
--bucket
is the S3 bucket name.--region
is the S3 bucket's region.--endpoint
is the S3 bucket's endpoint.--direction
specifies the upload direction.--localfile
is the local file to be uploaded.--remotefile
is the destination file in object storage.Download a File from S3 to Local
To download s3://logs/tmp.log
to the local file ./tmp1.log
:
/usr/local/bin/opscli file --direction download --localfile ./tmp1.log --remotefile s3://logs/tmp.log --bucket obs-test
- Unset AK/SK
To clear the AK/SK environment variables:
unset ak
unset sk
2. Host - Local and API Server File Transfer
This option provides encryption/decryption for file transfers with the API server.
- Upload to API Server
/usr/local/bin/opscli file --direction upload --api https://uploadapi.vinqi.com/api/v1/files --aeskey "" --localfile ./tmp.log
If aeskey
is not provided (or set as an empty string), a random encryption key is generated automatically.
- Download from API Server
/usr/local/bin/opscli file --api https://uploadapi.vinqi.com/api/v1/files --aeskey xxx --direction download --remotefile https://download_url_link.com.aes
3. Cluster - Local and API Server File Transfer
- Upload to Cluster's API Server
/usr/local/bin/opscli file -i ~/.kube/config --nodename node1 --direction upload --api https://uploadapi.vinqi.com/api/v1/files --aeskey "" --localfile /root/tmp.log --runtimeimage shaowenchen/ops-cli
- Download from Cluster's API Server
/usr/local/bin/opscli file -i ~/.kube/config --nodename xxx --direction download --api https://uploadapi.vinqi.com/api/v1/files --aeskey xxx --localfile /root/tmp1.log --remotefile https://uploadapi.vinqi.com/uploadbases/cdn0/raw/1721621949-tmp.log.aes --runtimeimage shaowenchen/ops-cli
4. Cluster - Local and Object Storage File Transfer
- Upload to Object Storage from Cluster
/usr/local/bin/opscli file -i ~/.kube/config --nodename xxx --direction upload --ak xxx --sk xxx --region beijing --endpoint ks3-cn-beijing.ksyun.com --bucket multimodal --localfile /root/tmp.log --remotefile s3://logs/tmp.log --runtimeimage shaowenchen/ops-cli
- Download from Object Storage to Cluster
/usr/local/bin/opscli file -i ~/.kube/config --nodename xxx --direction download --ak xxx --sk xxx --region beijing --endpoint ks3-cn-beijing.ksyun.com --bucket multimodal --localfile /root/tmp2.log --remotefile s3://logs/tmp.log --runtimeimage shaowenchen/ops-cli
5. Cluster - Copy Image File to Local
To copy an image file from the cluster to the local machine:
/usr/local/bin/opscli file -i ~/.kube/config --nodename xxx --direction download --localfile /root/opscli-copy --remotefile shaowenchen/ops-cli:latest:///usr/local/bin/opscli
This command helps copy the executable or file from a container/image inside the cluster to the local machine.