Skip to main content

GitLab

Nobl9 and GitLab have partnered to build a CI script to enable SLOs-as-Code for GitLab users. When using GitLab as the source repository, you can check the SLO YAML definitions along with your product code. Then, the CI script ensures any changes to the YAML file are automatically pushed to Nobl9 through sloctl.

What is GitLab?โ€‹

GitLab is a DevOps platform that allows users to develop, secure, and operate software in a single application. It's a web-based Git repository that provides open and private repositories for free, as well as wikis and issue-tracking capabilities.

Nobl9 and GitLabโ€‹

With the CI configuration, GitLab calls sloctl every time you build your repo and pushes the SLO definitions to Nobl9. This means you can use GitLab to version your SLO definitions and be sure that the definitions in Nobl9 are kept consistent and up to date. The CI script removes any doubt about what the most recent version is, allowing you to take the appropriate action when your error budget is burning too fast or is about to be exhausted.

Setting up Nobl9 CI script in GitLabโ€‹

Follow these steps to set up the Nobl9 CI script in GitLab:

  1. Log in to your GitLab account.

  2. Go to Settings > CI/CD > Variables, and click the Expand button.

    Image 1: Setting up the Nobl9 CI script in GitLab
  3. Add the following variables:

    Image 2: Adding variables to the Nobl9 CI script in GitLab
    • ACCESS_TOKEN - used to authenticate the sloctl. The Access Token consists of your Client ID and Client Secret (base64enc(${clientId}:${clientSecret})), which you can generate in the Nobl9 UI. For more detailed information, refer to the sloctl User Guide | Nobl9 Documentation. If you already have sloctl installed on your local machine, you can retrieve your Access Token using the following command cat ~/.config/nobl9/config.toml.

    • CLIENT_ID - the Client ID of your Nobl9 account. For information on creating a Client ID, refer to the sloctl User Guide | Nobl9 Documentation.

    • CLIENT_SECRET - the Client Secret of your Nobl9 account. For information on creating a Client Secret, refer to the sloctl User Guide | Nobl9 Documentation.

    • PROJECT - the name of the project in Nobl9 that your SLO belongs to.

    • SLOCTL_YML - the path to the sloctl YAML file you want to push to Nobl9 each time a change is made.

  1. Create the CI/CD job to apply the YAML. In GitLabโ€™s UI, go to CI/CD -> Jobs, and click the Create CI/CD configuration file button.

    Image 3: Creating the CI/CD job to apply the YAML
  2. Enter the following code in the .gitlab.ci.yml file:

    variables:
    CLIENT_ID: $NOBL9_CLIENT_ID
    CLIENT_SECRET: $NOBL9_CLIENT_SECRET
    ACCESS_TOKEN: $NOBL9_ACCESS_TOKEN
    PROJECT: $NOBL9_PROJECT
    SLOCTL_YML: $SLOCTL_YML

    include:
    - project: 'nobl9/nobl9-ci-template'
    ref: main
    file: '/nobl9.gitlab-ci.yml'

Once you set up the Nobl9 CI script, any changes to the SLOCTL_YML file you reference are automatically pushed to Nobl9 once the updates are committed.