diff --git a/task/remote-scp/0.1/README.md b/task/remote-scp/0.1/README.md new file mode 100644 index 00000000..3543cd1a --- /dev/null +++ b/task/remote-scp/0.1/README.md @@ -0,0 +1,111 @@ +# Remote SCP +Remote SCP is a simple tool to copy files from a remote local machine to your server. + +## Install the Task +``` +kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/remote-scp/0.1/raw +``` +## Parameters +HOST: The server host to which you want to connect. (Required) +USERNAME: Connect as an user. (Required) +PORT: Port number to connect (default: 22). +TO_PATH: The path to which you want to copy the file. (Required) +LOCAL_PATH: The path of the file to be copied. (Required) + +## Workspaces +- credentials: The workspace contains secrets can be used to authenticate with the HOST. + Secrets + id_rsa: The private key of the user. +- storage: The workspace contains the file to be copied. + PersistentVolumeClaim +## Platforms +The Task can be run on linux/amd64 platform. +## Usage +1. Create the Secret by putting in the required values +```yaml +--- +apiVersion: v1 +kind: Secret +type: Opaque +metadata: + name: remote-scp-secret +data: + id_rsa: | + +``` +2. Create the PVC +```yaml +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: test-pv +spec: + storageClassName: manual + capacity: + storage: 2Gi + accessModes: + - ReadWriteMany + persistentVolumeReclaimPolicy: Retain + nfs: + path: /nfs/path/ + server: 127.0.0.1 +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: test-pvc +spec: + storageClassName: manual + accessModes: + - ReadWriteMany + resources: + requests: + storage: 2Gi +``` +3. Create Test File +```bash +touch /nfs/path/test.txt +``` +4. Create the TaskRun +```yaml +apiVersion: tekton.dev/v1beta1 +kind: TaskRun +metadata: + name: remote-scp-run +spec: + taskRef: + name: remote-scp + workspaces: + - name: credentials + secret: + secretName: remote-scp-secret + - name: storage + persistentVolumeClaim: + claimName: test-pvc + params: + - name: HOST + value: "server.boychai.xyz" + - name: PORT + value: "45" + - name: USERNAME + value: "root" + - name: TO_PATH + value: "/temp/" + - name: LOCAL_PATH + value: "test.txt" +``` + +## Output +```text +drone-scp version: v1.6.14 +tar all files into /tmp/OUGGuOpyIt.tar.gz +remote server os type is unix +scp file to server. +create folder /temp/ +remove file OUGGuOpyIt.tar.gz +untar file OUGGuOpyIt.tar.gz +=================================================== +✅ Successfully executed transfer data to all host +=================================================== +``` \ No newline at end of file diff --git a/task/remote-scp/0.1/remote-scp.yaml b/task/remote-scp/0.1/remote-scp.yaml new file mode 100644 index 00000000..4e5f0e90 --- /dev/null +++ b/task/remote-scp/0.1/remote-scp.yaml @@ -0,0 +1,45 @@ +apiVersion: tekton.dev/v1 +kind: Task +metadata: + name: remote-scp + labels: + app.kubernetes.io/version: "0.1" + annotations: + tekton.dev/pipelines.minVersion: "0.50.0" + tekton.dev/categories: Developer Tools + tekton.dev/tags: scp,remote + tekton.dev/displayName: "scp remote" + tekton.dev/platforms: "linux/amd64" +spec: + description: >- + The following tasks can be used to remotely upload files. + workspaces: + - name: credentials + description: >- + SSH private key + - name: storage + description: >- + External storage + params: + - name: HOST + type: string + description: Remote host to connect + - name: USERNAME + type: string + description: SSH username + - name: PORT + type: string + description: SSH port, default is 22 + default: "22" + - name: TO_PATH + type: string + description: upload to path + - name: LOCAL_PATH + type: string + description: local path + steps: + - name: put + image: docker.io/appleboy/drone-scp:1.6.14@sha256:0e0597678b948b0aa09888c66ac75af904cce81baf6af955208527d259c61818 + script: | + cd "$(workspaces.storage.path)" || exit + drone-scp --host "$(params.HOST)" --port "$(params.PORT)" --username "$(params.USERNAME)" --key-path "$(workspaces.credentials.path)/id_rsa" --target "$(params.TO_PATH)" --source "$(params.LOCAL_PATH)" diff --git a/task/remote-scp/0.1/samples/run.yaml b/task/remote-scp/0.1/samples/run.yaml new file mode 100644 index 00000000..3249d79e --- /dev/null +++ b/task/remote-scp/0.1/samples/run.yaml @@ -0,0 +1,23 @@ +apiVersion: tekton.dev/v1beta1 +kind: TaskRun +metadata: + name: remote-scp-run +spec: + taskRef: + name: remote-scp + workspaces: + - name: credentials + secret: + secretName: remote-scp-secret + - name: storage + persistentVolumeClaim: + claimName: test-pvc + params: + - name: HOST + value: "127.0.0.1" + - name: USERNAME + value: "user" + - name: TO_PATH + value: "/temp/" + - name: LOCAL_PATH + value: "local_PATH" \ No newline at end of file diff --git a/task/remote-scp/0.1/samples/secrets.yaml b/task/remote-scp/0.1/samples/secrets.yaml new file mode 100644 index 00000000..55b6d8d7 --- /dev/null +++ b/task/remote-scp/0.1/samples/secrets.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +type: Opaque +metadata: + name: remote-scp-secret +data: + id_rsa: your private ssh key in base64 \ No newline at end of file diff --git a/task/remote-scp/0.1/samples/storage.yaml b/task/remote-scp/0.1/samples/storage.yaml new file mode 100644 index 00000000..fa816d52 --- /dev/null +++ b/task/remote-scp/0.1/samples/storage.yaml @@ -0,0 +1,27 @@ +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: test-pv +spec: + storageClassName: manual + capacity: + storage: 2Gi + accessModes: + - ReadWriteMany + persistentVolumeReclaimPolicy: Retain + nfs: + path: /nfs/path/ + server: 127.0.0.1 +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: test-pvc +spec: + storageClassName: manual + accessModes: + - ReadWriteMany + resources: + requests: + storage: 2Gi \ No newline at end of file