info
Prerequisites - before you begin, please ensure:
- You have an active Ionburst Cloud account.
- You have created an Ionburst Cloud party and access credentials.
- You have downloaded and installed the IonFS CLI - version 0.3.0 or newer.
- You have created and configured an IonFS metadata repository on AWS S3.
- You have configured the IonFS CLI for S6 on your local machine.
Overview
As covered previously in our GitLab backup tutorial, we (Ionburst) use IBC S6 to protect the backups from our internal GitLab instance. In this tutorial, we will look at the other way we use IBC S6 with GitLab; as artifact storage for our GitLab CI/CD builds.
For this tutorial, we'll be using a GitLab repository containing the base code for our namegen
utility. We'll add a GitLab CI/CD config file to build the application, then use IonFS CLI to store the build artifact in IBC S6. Finally, we'll download the artifact to the local machine using IonFS CLI, and execute it.
One key point to note for this tutorial: we will be using an IonFS metadata repository set up in Amazon S3. As our GitLab CI/CD pipelines will be running in a containerised, ephemeral environment, this ensures the IonFS metadata is persisted elsewhere. It will also allow the build artifact to be downloaded to the local machine at the end of the tutorial.
Shared Responsibility Model Breakdown
Customer Responsibility
- You, the customer, are responsible for the secure management of the Ionburst Cloud credentials used by
ionfs
. - You, the customer, are responsible for the security of
ionfs
metadata repositories and the metadata stored in them. - You, the customer, are responsible for the security of the GitLab application and underlying instance - if self-hosting GitLab.
- You, the customer, are responsible for the security of the GitLab projects used in conjunction with this tutorial.
Ionburst Cloud Responsibility
- We are responsible for the security of GitLab backup data stored in IBC S6 using
ionfs
. - We are responsible for the underlying security and availability of the Ionburst Cloud platform.
GitLab CI/CD
To enable GitLab CI/CD for a project, a file, gitlab-ci.yml
, is added to the root of the project. Within this file, the concepts of stages and jobs are used to define the tasks needed to build, test, and deploy an application or piece of software.
For this tutorial, we will be creating a single build stage, with a job that will compile our namegen
application, then upload the binary to IBC S6.
Setting up the repository
First, we'll add a .gitlab-ci.yml
file to the root of our project.
To break this file down:
image
is the Docker image we're going to run our pipeline with, the defined image has both Go andionfs
installed.stages
defines the different pipeline stages, we're only specifying a build stage.compile_linux_amd64
:- this is our configured job, running in the
build
stage - the
before_script
is ensuring thego
command is available in the$PATH
, creating the~/.ionfs
config directory and file, creating a build directory, then setting an environment variable with semantic version for our build. - the
script
is building ournamegen
binary, and embedding our version in the build, then uploading the binary to IBC S6, before listing the IonFS metadata repository.
- this is our configured job, running in the
Before we commit the .gitlab-ci.yml
file to our repository, we first need to add some environment variables to our repository CI/CD configuration:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_REGION
IONBURST_ID
IONBURST_KEY
IONBURST_URI
IONFS_CONFIG
The IONFS_CONFIG
variable should be of type "file" and look like the following:
Once these environment variables have been configured, we can commit the gitlab-ci.yml
to our repository to kick off the first pipeline, which looks something like:
Retrieving the artifact
Now that we've successfully deployed our pipeline, our artifact is safely stored in IBC S6, and ready to be consumed or accessed. For our internal usage at Ionburst, this is typically to be picked up by a container build, or to distribute internally.
We can demonstrate the latter by configuring the IonFS repo and appropriate credentials used in our pipeline on our local machine. Once setup, we can list the repo, download our namegen
artifact, and run it locally:
Example output:
Wrapping up
In this tutorial, we've covered some background on GitLab CI/CD artifacts and how to protect them with IBC S6 and IonFS CLI.
All the steps covered in this tutorial are currently used by Ionburst Cloud to protect our internal build artifacts. To keep up with the latest developments on using IonFS CLI with GitLab CI/CD, please checkout out our example repository on GitHub.