In the realm of continuous integration and deployment (CI/CD) pipelines, the seamless transfer of artifacts to any remote servers holds immense significance.
Traditionally, in the case of NFS, achieving this demands mounting of the nfs share inside the runner, thereby restricting it to a specific node and granting privileged access.
However, NCP (NFS Copy), can be utilized to
allows direct artifact copying to remote NFS servers without the need for mounting, eliminating the constraints of privileged access.
In this article, we delve into the utilization of NCP in GitLab pipelines.
Understanding the Pipeline
Let's examine a sample pipeline to better understand how NCP can be leveraged for artifact transfer:
stages:
- build
- publish
build:
stage: build
script:
- echo "build test artifact" > output.txt
artifacts:
paths:
- output.txt
expire_in: 2 hours
publish:
stage: publish
needs: ["build"]
image: docker.io/khaliq/ncp:latest
script:
- ncp to --host 192.168.0.80 --nfspath data --input output.txt
The pipeline consists of two stages: build
and publish
. In the build
stage, a test artifact is created by echoing the text "build test artifact" into a file called output.txt
.
This stage is responsible for building the artifact that will later be transferred to the remote NFS server.
publish:
stage: publish
needs: ["build"]
image: docker.io/khaliq/ncp:ncp
script:
- ncp to --host 192.168.0.80 --nfspath data --input output.txt
The publish stage is where the artifact is transferred using NCP. Here's a breakdown of the command used:
ncp to
: Specifies the direction of the transfer, indicating that the artifact will be sent to the remote server.
--host
: Specifies the IP address or hostname of the remote NFS server.
--nfspath
: Defines the target path on the remote server where the artifact will be stored.
--input
: Specifies the input artifact to be transferred, in this case, output.txt
.
With this simple command, it handles the transfer of the artifact to the specified remote NFS server, without the need to mount nfs shares.
Conclusion
NCP simplifies remote NFS server integration in CI/CD pipelines. By eliminating nfs share mounting and the need for privileged access, it streamlines artifact transfer, granting the freedom to run jobs anywhere.
Checkout the GitHub repository for more information.
Top comments (0)