Gitlab Runner

一、简介

Gitlab Runner是Gitlab Pipeline中各阶段Job任务中脚本执行的承载者。

二、原理

1、Runner说明

2、Runner执行器工作流

执行器为kubernetes的runner的工作流

三、注册Runner

1、在Gitlab中获取Runner的注册信息

2、Runner注册流程

Runtime platform         arch=amd64 os=linux pid=48 revision=2ebc4dc4 version=13.9.0
Running in system-mode.

Enter the GitLab instance URL (for example, https://gitlab.com/):
# 输入gitlab实例的地址

Enter the registration token:
# 输入向gitlab实例注册的Token

Enter a description for the runner:
[759510becaba]: # 输入对当前gitlab runner的描述信息

Enter tags for the runner (comma-separated):
# 输入当前gitlab runner的标签
Registering runner... succeeded                     runner=Db2NbZ2M

Enter an executor: docker-ssh+machine, kubernetes, custom, docker, parallels, virtualbox, docker+machine, docker-ssh, shell, ssh:
# 输入当前gitlab runner的执行器类型  docker

Enter the default Docker image (for example, ruby:2.6):
# 输入当前gitlab runner的执行器默认使用的docker镜像  alpine:latest

Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!

四、Runner部署及配置

1、Docker

部署runner

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

注册runner

docker exec -it gitlab-runner gitlab-runner register \
    --non-interactive \
  --url # gitlab地址 \
  --registration-token # gitlab的runner注册Token \
  --executor # 执行器 \
  --description # "runner的详细描述" \
  --docker-image # 默认镜像 \
  --docker-privileged \
  --docker-pull-policy # "镜像拉取策略" \
  --tag-list # "runner 标签"

2、二进制

部署runner

# Linux x86-64 / Linux x86 / Linux arm / Linux arm64 / Linux s390x
arch=[ amd64,386,arm,arm64,s390x ]
curl -L -o /usr/local/bin/gitlab-runner "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-$arch" && \
chmod +x /usr/local/bin/gitlab-runner && \
useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash && \
gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner && \
gitlab-runner start

注册 runner

gitlab-runner register \
    --non-interactive \
  --url # gitlab地址 \
  --registration-token # gitlab的runner注册Token \
  --executor # 执行器 \
  --description # "runner的详细描述" \
  --docker-image # 默认镜像 \
  --docker-privileged \
  --docker-pull-policy # "镜像拉取策略" \
  --tag-list # "runner 标签"

3、Kubernetes

helm repo add gitlab https://charts.gitlab.io
helm update

编写helm charts values.yaml配置文件

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

五、Runner与Pipeline的流程图

Copyright Curiouser all right reserved,powered by Gitbook该文件最后修改时间: 2022-05-16 17:26:46

results matching ""

    No results matching ""