bil / gitlab-runner-gke-autopilot

Instructions on how to deploy GitLab Runner Kubernetes Executor with GKE Autopilot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitLab Runner Kubernetes Executor with Google Kubernetes Engine Autopilot

This document details deployment of the GitLab Runner Kubernetes Executor Helm Chart on GKE Autopilot.

While most elements work without modification, some Autopilot-specific changes are necessary.

Changes to default values.yaml

Required changes

Below are the minimum number of changes to the default values.yaml to run in GKE Autopilot.

  • Set gitlabUrl to URL of instance (~L50):

    gitlabUrl: <URL to base GitLab install>

  • Set runnerRegistrationToken for project/group/subgroup (~L55):

    runnerRegistrationToken: "<runner registration token>"

  • Enable rbac (~L140):

     rbac:
       create: true
    
  • Define a node selector to ensure executor lives in a separate workload to avoid preempting of the runner pod by jobs or cluster services (~L620):

     nodeSelector:
         group: autopilot-executor
    
  • Set the corresponding toleration (~L625):

     tolerations:
       - key: group
         operator: Equal
         value: autopilot-executor
         effect: NoSchedule
    

Recommended changes

  • Set runner tag (~L360):

      tags: <runner tag>
    
  • Diable running untagged (~L375):

      runUntagged: false
    
  • Increase concurrency (~L95). Each 100 jobs consume approximately 0.25 CPU and 0.25 GB RAM.

      concurrent: 400
    
  • Set higher runner pod resources (~L600):

      resources:
        cpu: 1
        memory: 1Gi
    
  • Provide additional updates to job pods config, run all job pods as spot VMs (~L315):

      config: |
        [[runners]]
          [runners.kubernetes]
            namespace = "{{.Release.Namespace}}"
            image = "ubuntu:22.04"
            poll_timeout = 3600
            cpu_request = "500m"
            cpu_request_overwrite_max_allowed = 50
            memory_request = "256M"
            memory_request_overwrite_max_allowed = "256G"
            ephemeral_storage_request = "10G"
            ephemeral_storage_request_overwrite_max_allowed = "5T"
            helper_cpu_request = "500m"
            helper_cpu_request_overwrite_max_allowed = "5"
            helper_memory_request = "256M"
            helper_memory_request_overwrite_max_allowed = "2G"
            helper_ephemeral_storage_request = "5G"
            helper_ephemeral_storage_request_overwrite_max_allowed = "20G"
            node_selector_overwrite_allowed = ".*"
          [runners.kubernetes.node_selector]
            "cloud.google.com/gke-spot" = "true"
    

Deployment

Deploy with helm, recommend deploying from Google Cloud Shell after setting a default kubectl cluster:

helm install gitlab-runner -f values.yaml gitlab/gitlab-runner

Subsequent updates to values.yaml configuration can be propogated with helm upgrade:

helm upgrade gitlab-runner -f values.yaml gitlab/gitlab-runner

Usage

Run computational pipelines with GitLab CI/CD defined in a repository's .gitlab-ci.yml.

Resources can be specified on a per-job basis using the KUBERNETES_ container override variables.

About

Instructions on how to deploy GitLab Runner Kubernetes Executor with GKE Autopilot