DevOps GitLab CICD 实践2——Runner 部署

栏目: 编程工具 · 发布时间: 5年前

内容简介:虽然有官方指引,但个人感觉指引的不够清晰,导致初次配置可能频繁失败可以通过Gitlab管理员账号获取,也可以让每一个用户自行配置

文档地址

虽然有官方指引,但个人感觉指引的不够清晰,导致初次配置可能频繁失败

Run GitLab Runner in a container

This is how you can run GitLab Runner inside a Docker container.

General GitLab Runner Docker image usage

GitLab Runner Docker images (based on Ubuntu or Alpine Linux ) are designed as wrappers around the standard gitlab-runner command, like if GitLab Runner was installed directly on the host.

The general rule is that every GitLab Runner command that normally would be executed as:

gitlab-runner [Runner command and options...]
复制代码

can be executed with:

docker run [chosen docker options...] gitlab/gitlab-runner [Runner command and options...]
复制代码

For example, getting the top-level help information for GitLab Runner command could be executed as:

docker run --rm -t -i gitlab/gitlab-runner --help

NAME:
   gitlab-runner - a GitLab Runner

USAGE:
   gitlab-runner [global options] command [command options] [arguments...]

VERSION:
   10.7.0 (7c273476)

(...)
复制代码

In short, the gitlab-runner part of the command is replaced with docker run [docker options] gitlab/gitlab-runner , while the rest of Runner’s command stays as it is described in the register documentation . The only difference is that the gitlab-runner command is executed inside of a Docker container.

Docker image installation and configuration

  1. Install Docker first:

    curl -sSL https://get.docker.com/ | sh
    复制代码
  2. You need to mount a config volume into the gitlab-runner container to be used for configs and other resources:

    docker run -d --name gitlab-runner --restart always \
       -v /srv/gitlab-runner/config:/etc/gitlab-runner \
       -v /var/run/docker.sock:/var/run/docker.sock \
       gitlab/gitlab-runner:latest
    复制代码

    Tip:On macOS, use /Users/Shared instead of /srv .

    Or, you can use a config container to mount your custom data volume:

    docker run -d --name gitlab-runner-config \
         -v /etc/gitlab-runner \
         busybox:latest \
         /bin/true
    复制代码

    And then, run the Runner:

    docker run -d --name gitlab-runner --restart always \
         -v /var/run/docker.sock:/var/run/docker.sock \
         --volumes-from gitlab-runner-config \
         gitlab/gitlab-runner:latest
    复制代码
  3. Register the runner you just launched by following the instructions in the Docker section of Registering Runners . The runner won’t pick up any jobs until it’s registered.

安装步骤

获取Gitlab Runner秘钥

可以通过Gitlab管理员账号获取,也可以让每一个用户自行配置

  • 普通用户查看秘钥

进入任意一个仓库的设置中,查看CICD配置

DevOps GitLab CICD 实践2——Runner 部署

准备注册专用Runner令牌

DevOps GitLab CICD 实践2——Runner 部署
  • 管理员查看令牌

进入总设置页面,配置全局Runner令牌

DevOps GitLab CICD 实践2——Runner 部署

Runner注册

由于Runner一般运行复杂构建、打包任务,推荐配置在性能、带宽更大的机房

准备 Docker 环境

$ curl -sSL https://get.docker.com/ | sh
$ systemctl start docker
复制代码

注册

可以根据需要选择注册Runner类型

同时,为了方便配置,使用单行注册并且关闭交互

单行注册官方文档

命令说明:

-v
--rm
-it
$ docker run --rm -it \
  -v /www/wwwroot/gitlab/srv/gitlab-runner/config:/etc/gitlab-runner \
  gitlab/gitlab-runner:alpine-v11.8.0 register \
  --non-interactive \
  --executor "docker" \
  --docker-image docker:stable \
  --url "Gitlab URL" \
  --registration-token "令牌" \
  --description "描述" \
  --tag-list "标签1,标签2" \
  --run-untagged \
  --docker-privileged \
  --locked="false"
复制代码

注册成功提示

DevOps GitLab CICD 实践2——Runner 部署

此时管理面板显示新的Runner已经注册

DevOps GitLab CICD 实践2——Runner 部署

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Django 1.0 Template Development

Django 1.0 Template Development

Scott Newman / Packt / 2008 / 24.99

Django is a high-level Python web application framework designed to support the rapid development of dynamic websites, web applications, and web services. Getting the most out of its template system a......一起来看看 《Django 1.0 Template Development》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具