Skip to main content

GitLab

Reading time: 0 minute(s) (0 words)

Nobl9 and GitLab have partnered to build a CI script to activate 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 - a JWT token retrieved from Okta, used by sloctl to authenticate with Nobl9. You can retrieve the Access Token in two ways:

      • Use the Nobl9 API by following the steps described here.

      • If you have sloctl installed on your local machine, use the following command:

        grep accessToken ~/.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.

    • CLIENT_SECRET - the Client Secret of your Nobl9 account. For information on creating a Client Secret, refer to the sloctl user guide.

    • 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.

  4. 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
  5. 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.