Git Product home page Git Product logo

gitlab-ci-runner-marathon's Introduction

gitlab-ci-runner-marathon

Build Status Docker Stars Docker Pulls

A customized Docker image for running scalable GitLab CI runners on DC/OS via Marathon.

Configuration

The GitLab runner can be configured by environment variables. For a complete overview, have a look at the docs/gitlab_runner_register_arguments.md file.

The most important ones are:

  • GITLAB_SERVICE_NAME: The Mesos DNS service name of the GitLab instance, e.g. gitlab.marathon.mesos. This strongly depends on your setup, i.e. how you launched GitLab and how you configured Mesos DNS. This is the recommended method to use with DC/OS installations of GitLab. Either this environment variable or GITLAB_INSTANCE_URL is mandatory.
  • GITLAB_INSTANCE_URL: The URL of the GitLab instance to connect to, e.g. http://gitlab.mycompany.com. Either this environment variable or GITLAB_SERVICE_NAME is mandatory.
  • REGISTRATION_TOKEN: The registration token to use with the GitLab instance. See the docs for details. (mandatory)
  • RUNNER_EXECUTOR: The type of the executor to use, e.g. shell or docker. See the executor docs for more details. (mandatory)
  • RUNNER_CONCURRENT_BUILDS: The number of concurrent builds this runner should be able to handel. Default is 1.
  • RUNNER_TAG_LIST: If you want to use tags in you .gitlab-ci.yml, then you need to specify the comma-separated list of tags. This is useful to distinguish the runner types.

Using private Docker registries with GitLab Runner

Private Docker registries can be used by adding the secret variable DOCKER_AUTH_CONFIG to your project's Settings โž” CI/CD Pipelines settings. Have a look at the guide as well.

Run on DC/OS

This version of the GitLab CI runner for Marathon project uses Docker-in-Docker techniques, with all of its pros and cons. See also jpetazzo's article on this topic.

In the following examples, we assume that you're running the GitLab Universe package as service gitlab on the DC/OS internal Marathon instance, which is also available to the runners via the external_url of the GitLab configuration. This normally means that GitLab is exposed on a public agent node via marathon-lb. Please see the [example documentation here|https://github.com/dcos/examples/tree/master/1.8/gitlab].

Shell runner

An example for a shell runner. This enables the build of Docker images.

{
  "id": "gitlab-runner-shell",
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "tobilg/gitlab-ci-runner-marathon:v13.4.1",
      "network": "HOST",
      "forcePullImage": true,
      "privileged": true
    }
  },
  "instances": 1,
  "cpus": 1,
  "mem": 2048,
  "env": {
    "GITLAB_SERVICE_NAME": "gitlab.marathon.mesos",
    "REGISTRATION_TOKEN": "zzNWmRE--SBfeMfiKCMh",
    "RUNNER_EXECUTOR": "shell",
    "RUNNER_TAG_LIST": "shell,build-as-docker",
    "RUNNER_CONCURRENT_BUILDS": "4"
  },
  "taskKillGracePeriodSeconds": 15,
  "healthChecks": [
     {
       "path": "/metrics",
       "portIndex": 0,
       "protocol": "HTTP",
       "gracePeriodSeconds": 300,
       "intervalSeconds": 60,
       "timeoutSeconds": 20,
       "maxConsecutiveFailures": 3,
       "ignoreHttp1xx": false
     }
  ]
}

Docker runner

Here's an example for a Docker runner, which enables builds inside Docker containers:

{
  "id": "gitlab-runner-docker",
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "tobilg/gitlab-ci-runner-marathon:v13.4.1",
      "network": "HOST",
      "forcePullImage": true,
      "privileged": true
    }
  },
  "instances": 1,
  "cpus": 1,
  "mem": 2048,
  "env": {
    "GITLAB_SERVICE_NAME": "gitlab.marathon.mesos",
    "REGISTRATION_TOKEN": "zzNWmRE--SBfeMfiKCMh",
    "RUNNER_EXECUTOR": "docker",
    "RUNNER_TAG_LIST": "docker,build-in-docker",
    "RUNNER_CONCURRENT_BUILDS": "4",
    "DOCKER_IMAGE": "node:6-wheezy"
  },
  "taskKillGracePeriodSeconds": 15,
  "healthChecks": [
     {
        "path": "/metrics",
        "portIndex": 0,
        "protocol": "HTTP",
        "gracePeriodSeconds": 300,
        "intervalSeconds": 60,
        "timeoutSeconds": 20,
        "maxConsecutiveFailures": 3,
        "ignoreHttp1xx": false
      }
  ]
}

Make sure you choose a useful default Docker image via DOCKER_IMAGE, for example if you want to build Node.js projects, the node:6-wheezy image. This can be overwritten with the image property in the .gitlab-ci.yml file (see the GitLab CI docs.

Usage in GitLab CI

Builds as Docker

An .gitlab-ci.yml example of using the build-as-docker tag to trigger a build on the runner(s) with shell executors:

stages:
  - ci

build-job:
  stage: ci
  tags:
    - build-as-docker
  script:
    - docker build -t tobilg/test .

This assumes your project has a Dockerfile, for example

FROM nginx

Builds in Docker

An .gitlab-ci.yml example of using the build-in-docker tag to trigger a build on the runner(s) with Docker executors:

image: node:6-wheezy

stages:
  - ci

test-job:
  stage: ci
  tags:
    - build-in-docker
  script:
    - node --version

gitlab-ci-runner-marathon's People

Contributors

ssk2 avatar tobilg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gitlab-ci-runner-marathon's Issues

Upgrade image

This as not been upgrading for a long time.

Since 13.0.4 and my root certificate expiring just today, I am not able to git clone without configuring ca_cert in the runner toml configuration. I am not sure what of those two is the cause, but upgrading the image would help.

I see bunch of options in the latest runner version that I can't use like pre_clone_script`` in https://gitlab.com/gitlab-org/gitlab-runner/-/issues/986#note_39714398

NB: I still have issue to set multiple time the same environment variable.

[Upgrade] upgrade to gitlab 11

Hi @tobilg , Our config.toml is not able anymore to use extra_hosts = ["ldap:225.45.35.125"], could you please upgrade the image for Gitlab 11? Thanks in advance.

How to set multiple host with DOCKER_EXTRA_HOSTS

I am using $DOCKER_EXTRA_HOSTS and I need to set multiple hosts.

I have tried DOCKER_EXTRA_HOSTS=private:172.16.50.52,npm.example.com:172.16.50.53

ERROR: Preparation failed: Error response from daemon: invalid IP address in add-host: "172.16.50.52,npm.example.com:172.16.50.53"

I have tried DOCKER_EXTRA_HOSTS=private:172.16.50.52 --add-host npm.example.com:172.16.50.53

ERROR: Preparation failed: Error response from daemon: invalid IP address in add-host: "172.16.50.52 --add-host npm.example.com:172.16.50.53"

What is the recommended way to set multiple hosts?

Broken with Gitlab upgrade = 12.10.14 (fe3e5d62b3e)

After upgrading my Gitlab instance to 12.10.14 (fe3e5d62b3e), my runner is failing to connect to GitLab:

Checking for jobs... received job=2401 https://git.mydomain.com/mynamespace/myproject.git runner=8yHz4ift

How can I fix the runners to keep GitLab up to date ?

Thanks a lot.

Allow for non-mesos gitlab instances

Can GITLAB_SERVICE_NAME be used directly as the gitlab server url in CI_SERVER_URL if it starts with http, or some other way of providing the url indicating an installation outside of the mesos cluster? I'm new to Mesos but this seems to be an arbitrary limitation - it seems like this runner should be able to work completely independently of the gitlab service itself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.