Module deploys GitLab Runner into a Kubernetes cluster via Helm.

Module optionally deploys GitLab agent into a Kubernetes cluster via Helm.

Log in to Corewide IaC registry

Once you have a Corewide Solutions Portal account, this one-time action will use your browser session to retrieve credentials:

 shellterraform login solutions.corewide.com
Provision instructions

Initialize mandatory providers:

Copy and paste into your Terraform configuration and insert the variables:

 hclmodule "tf_k8s_gitlab_ci_runner" {
  source  = "solutions.corewide.com/kubernetes/tf-k8s-gitlab-ci-runner/helm"
  version = "~> 2.3.0"

  # specify module inputs here or try one of the examples below
  ...
}

Initialize the setup:

 shellterraform init
Define update strategy

Corewide DevOps team strictly follows Semantic Versioning Specification to provide our clients with products that have predictable upgrades between versions. We recommend pinning patch versions of our modules using pessimistic constraint operator (~>) to prevent breaking changes during upgrades.

To get new features during the upgrades (without breaking compatibility), use ~> 2.3 and run terraform init -upgrade

For the safest setup, use strict pinning with version = "2.3.0"

GitLab Runner for Kubernetes

GitLab Runner for Kubernetes deployed from Helm chart
Module
20% off
€1,100
€880
TOTAL €880
BUY
v2.3.0 released 1 month, 1 week ago
New version approx. every 24 weeks

Module deploys GitLab Runner into a Kubernetes cluster via Helm.

Module optionally deploys GitLab agent into a Kubernetes cluster via Helm.

Programmatically create a group runner and use the generated token for the authentication to the GitLab server:

NOTE: runner registration setup may differ based on the required runner type (group, project, or instance(shared)).

 hclresource "gitlab_user_runner" "main" {
  runner_type     = "group_type"
  group_id        = "1234567890"
  description     = "Main self-hosted runner"
  tag_list        = ["backend", "frontend"]
  untagged        = true
  maximum_timeout = 1800
  access_level    = "not_protected"
}

module "gitlab_runner" {
  source  = "solutions.corewide.com/kubernetes/tf-k8s-gitlab-ci-runner/helm"
  version = "~> 2.3"

  authentication_token = gitlab_user_runner.main.token
}

NOTE: GitLab provider must be authenticated with permissions to manage the CI runners.

Deploy GitLab Runner and GitLab agent with custom configuration:

 hclmodule "gitlab_runner" {
  source  = "solutions.corewide.com/kubernetes/tf-k8s-gitlab-ci-runner/helm"
  version = "~> 2.3"

  authentication_token = "glrt-aBCdef_123456-GhJkLMnOpQrSTU.78.90xyz"
  name_prefix          = "staging"
  gitlab_url           = "https://my-gitlab.com"
  namespace            = "ci"
  pipeline_image       = "alpine/git"
  chart_version        = "0.80.0-beta"
  app_version          = "ubi-fips"

  node_selector = {
    "eks.amazonaws.com/nodegroup" = "maintenance"
  }

  job_node_selector = {
    "eks.amazonaws.com/nodegroup" = "gitlab"
  }

  job_additional_labels = {
    "job_stage" = "$${CI_JOB_STAGE}"
  }

  custom_values = {
    podAnnotations = {
      "iam.amazonaws.com/role" = "arn:aws:iam::123456789012:role/application_abc/component_xyz/Access"
    }

    podLabels = {
      managed-by  = "terraform"
      environment = "development"
    }
  }

  agent = {
    enabled      = true
    access_token = "glagent-aBCdef_123456-GhJkLMnOpQrSTU.78.90xyz"

    custom_values = {
      replicas = 1

      podLabels = {
        managed-by  = "terraform"
        environment = "development"
      }
    }
  }
}

Deploy GitLab Runner with mandatory values only:

 hclmodule "gitlab_runner" {
  source  = "solutions.corewide.com/kubernetes/tf-k8s-gitlab-ci-runner/helm"
  version = "~> 2.3"

  authentication_token = "glrt-aBCdef_123456-GhJkLMnOpQrSTU.78.90xyz"
}
Variable Description Type Default Required Sensitive
authentication_token Authentication token for GitLab Runner string yes yes
name_prefix Name prefix for all the resources created by the module string yes no
agent GitLab agent parameters object {} no no
agent.access_token GitLab agent access token string no no
agent.app_version GitLab agent application version string v19.3.2 no no
agent.chart_version GitLab agent chart version string 2.31.0 no no
agent.custom_values Custom values for GitLab agent chart any {} no no
agent.enabled Whether GitLab agent should be enabled bool false no no
agent.kas_address GitLab Kubernetes agent server address string wss://kas.gitlab.com no no
agent.node_selector Node selector to place GitLab agent pods in. If it is not provided, the runner node selector is used map(string) {} no no
app_version GitLab Runner application version string alpine-v19.3.2 no no
chart_version GitLab Runner chart version string 0.92.1 no no
concurrent_jobs Number of pipelines running at the same time number 4 no no
create_namespace Indicates creation of dedicated namespace for GitLab Runner bool true no no
custom_values Custom values for GitLab Runner any {} no no
gitlab_url GitLab server URL to connect GitLab Runner to string https://gitlab.com no no
job_additional_labels Additional labels to add to pipeline jobs spawned by GitLab Runner map(string) {} no no
job_node_selector Node selector to place pipeline jobs spawned by GitLab Runner map(string) {} no no
job_service_account_name_prefix Name prefix of Service Accounts allowed to be used in CI job pods string gitlab-runner no no
namespace The namespace to install GitLab Runner into string gitlab no no
node_selector Node selector to place GitLab Runner itself in map(string) {} no no
pipeline_image Default container image to run pipeline steps in string docker:29.8-dind no no
termination_period The duration in seconds that the pod has to terminate gracefully, after the job completed number 1800 no no
Dependency Version Kind
terraform >= 1.0 CLI
hashicorp/helm ~> 3.1 provider
hashicorp/kubernetes ~> 3.0 provider

These components are included as is under the terms of their corresponding licenses.

Component License
GitLab Runner MIT
GitLab Runner Helm Chart MIT
GitLab Agent for Kubernetes MIT
GitLab Agent Helm Chart MIT

Not sure where to start?
Let's find your perfect match.