GitLab Runner Helm Chart

Note:These charts have been tested on Google Kubernetes Engine and Azure Container Service. Other Kubernetes installations may work as well, if not pleaseopen an issue.

Thegitlab-runnerHelm chart deploys a GitLab Runner instance into your Kubernetes cluster.

This chart configures the Runner to:

  • Run using the GitLab RunnerKubernetes executor
  • For each new job it receives fromGitLab CI, it will provision a new pod within the specified namespace to run it.

For more information on available GitLab Helm Charts, please see ouroverview.

Prerequisites

  • Your GitLab Server's API is reachable from the cluster
  • Kubernetes 1.4+ with Beta APIs enabled
  • ThekubectlCLI installed locally and authenticated for the cluster
  • TheHelm clientinstalled locally on your machine

Configuring GitLab Runner using the Helm Chart

Create avalues.yamlGitLab跑步者配置文件。看到Helm docsfor information on how your values file will override the defaults.

The default configuration can always be found in thevalues.yamlin the chart repository.

Required configuration

In order for GitLab Runner to function, your config filemustspecify the following:

  • gitlabUrl- the GitLab Server URL (with protocol) to register the runner against
  • runnerRegistrationToken- The Registration Token for adding new Runners to the GitLab Server. This must be retrieved from your GitLab Instance. See theGitLab Runner Documentationfor more information.

Unless you need to specify additional configuration, you areready to install.

Other configuration

The rest of the configuration isdocumented in thevalues.yamlin the chart repository.

Here is a snippet of the important settings:

## The GitLab Server URL (with protocol) that want to register the runner against## ref: https://docs.gitlab.com/runner/commands/README.html#gitlab-runner-register##gitlabUrl:http://gitlab.your-domain.com/## The Registration Token for adding new Runners to the GitLab Server. This must## be retrieved from your GitLab Instance.## ref: https://docs.gitlab.com/ce/ci/runners/README.html#creating-and-registering-a-runner##runnerRegistrationToken:""## Set the certsSecretName in order to pass custom certificates for GitLab Runner to use## Provide resource name for a Kubernetes Secret Object in the same namespace,## this is used to populate the /etc/gitlab-runner/certs directory## ref: https://docs.gitlab.com/runner/configuration/tls-self-signed.html#supported-options-for-self-signed-certificates###certsSecretName:## Configure the maximum number of concurrent jobs## ref: https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-global-section##concurrent:10## Defines in seconds how often to check GitLab for a new builds## ref: https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-global-section##checkInterval:30## For RBAC support:rbac:create:false## Run the gitlab-bastion container with the ability to deploy/manage containers of jobs## cluster-wide or only within namespaceclusterWideAccess:false## Use the following Kubernetes Service Account name if RBAC is disabled in this Helm chart (see rbac.create)### serviceAccountName: default## Configuration for the Pods that that the runner launches for each new job##runners:## Default container image to use for builds when none is specified##image:ubuntu:16.04## Run all containers with the privileged flag enabled## This will allow the docker:stable-dind image to run if you need to run Docker## commands. Please read the docs before turning this on:## ref: https://docs.gitlab.com/runner/executors/kubernetes.html#using-docker-dind##privileged:false## Namespace to run Kubernetes jobs in (defaults to 'default')### namespace:## Build Container specific configuration##builds:# cpuLimit: 200m# memoryLimit: 256MicpuRequests:100mmemoryRequests:128Mi## Service Container specific configuration##services:# cpuLimit: 200m# memoryLimit: 256MicpuRequests:100mmemoryRequests:128Mi## Helper Container specific configuration##helpers:# cpuLimit: 200m# memoryLimit: 256MicpuRequests:100mmemoryRequests:128Mi

Enabling RBAC support

If your cluster has RBAC enabled, you can choose to either have the chart create its own service account or provide one.

To have the chart create the service account for you, setrbac.createto true.

Controlling maximum Runner concurrency

A single GitLab Runner deployed on Kubernetes is able to execute multiple jobs in parallel by automatically starting additional Runner pods. Theconcurrentsettingcontrols the maximum number of pods allowed at a single time, and defaults to10.

## Configure the maximum number of concurrent jobs## ref: https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-global-section##concurrent:10

Running Docker-in-Docker containers with GitLab Runners

看到Running Privileged Containers for the Runnersfor how to enable it, and theGitLab CI Runner documentationon running dind.

Running privileged containers for the Runners

You can tell the GitLab Runner to run using privileged containers. You may need this enabled if you need to use the Docker executable within your GitLab CI jobs.

This comes with several risks that you can read about in theGitLab CI Runner documentation.

If you are okay with the risks, and your GitLab CI Runner instance is registered against a specific project in GitLab that you trust the CI jobs of, you can enable privileged mode invalues.yaml:

runners:## Run all containers with the privileged flag enabled## This will allow the docker:stable-dind image to run if you need to run Docker## commands. Please read the docs before turning this on:## ref: https://docs.gitlab.com/runner/executors/kubernetes.html#using-docker-dind##privileged:true

Providing a custom certificate for accessing GitLab

You can provide aKubernetes Secretto the GitLab Runner Helm Chart, which will be used to populate the container's/etc/gitlab-runner/certs目录中。

Each key name in the Secret will be used as a filename in the directory, with the file content being the value associated with the key.

More information on how GitLab Runner uses these certificates can be found in theRunner Documentation.

  • The key/file name used should be in the format.crt. For example:gitlab.your-domain.com.crt.
  • Any intermediate certificates need to be concatenated to your server certificate in the same file.
  • The hostname used should be the one the certificate is registered for.

The GitLab Runner Helm Chart does not create a secret for you. In order to create the secret, you can prepare your certificate on you local machine, and then run thekubectl create secretcommand from the directory with the certificate

kubectl--namespacecreate secret generic --from-file=
  • 是the Kubernetes namespace where you want to install the GitLab Runner.
  • 是the Kubernetes Secret resource name. For example:gitlab-domain-cert
  • 是the filename for the certificate in your current directory that will be imported into the secret

You then need to provide the secret's name to the GitLab Runner chart.

Add the following to yourvalues.yaml

## Set the certsSecretName in order to pass custom certificates for GitLab Runner to use## Provide resource name for a Kubernetes Secret Object in the same namespace,## this is used to populate the /etc/gitlab-runner/certs directory## ref: https://docs.gitlab.com/runner/configuration/tls-self-signed.html#supported-options-for-self-signed-certificates##certsSecretName:
  • 是the Kubernetes Secret resource name. For example:gitlab-domain-cert

Installing GitLab Runner using the Helm Chart

Add the GitLab Helm repository and initialize Helm:

helm repo add gitlab https://charts.gitlab.iohelm init

Once youhave configuredGitLab Runner in yourvalues.ymlfile, run the following:

helminstall--namespace--namegitlab-runner-f gitlab/gitlab-runner
  • 是the Kubernetes namespace where you want to install the GitLab Runner.
  • 是the path to values file containing your custom configuration. See the配置section to create it.

Updating GitLab Runner using the Helm Chart

Once your GitLab Runner Chart is installed, configuration changes and chart updates should we done usinghelm upgrade

helm upgrade--namespace-f  gitlab/gitlab-runner

Where:

  • 是the Kubernetes namespace where GitLab Runner is installed
  • 是the path to values file containing your custom configuration. See the配置section to create it.
  • 是the name you gave the chart when installing it. In theInstall sectionwe called itgitlab-runner.

Uninstalling GitLab Runner using the Helm Chart

To uninstall the GitLab Runner Chart, run the following:

执掌删除--namespace 

where:

  • 是the Kubernetes namespace where GitLab Runner is installed
  • 是the name you gave the chart when installing it. In theInstall sectionwe called itgitlab-runner.
Baidu
map