DevOps/GitLab

GitLab Runner 설치 및 등록

yscho03 2022. 5. 25. 20:16
728x90
반응형

설치 환경

  • ubuntu 20.04.1

 

설치 방법

1. 리포지토리 등록

amd64, arm, arm64 아키텍처가 있는 amd64로 한다.

root@master:~# curl -LJO "https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_amd64.deb"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  414M  100  414M    0     0  1909k      0  0:03:42  0:03:42 --:--:-- 1029k

2. 패키지 설치

root@master:~# dpkg -i gitlab-runner_amd64.deb
Selecting previously unselected package gitlab-runner.
(데이터베이스 읽는중 ...현재 274798개의 파일과 디렉터리가 설치되어 있습니다.)
Preparing to unpack gitlab-runner_amd64.deb ...
Unpacking gitlab-runner (15.0.0) ...
gitlab-runner (15.0.0) 설정하는 중입니다 ...
GitLab Runner: creating gitlab-runner...
Home directory skeleton not used
Runtime platform                                    arch=amd64 os=linux pid=14614 revision=febb2a09 version=15.0.0
gitlab-runner: the service is not installed
Runtime platform                                    arch=amd64 os=linux pid=14622 revision=febb2a09 version=15.0.0
gitlab-ci-multi-runner: the service is not installed
Runtime platform                                    arch=amd64 os=linux pid=14644 revision=febb2a09 version=15.0.0
Runtime platform                                    arch=amd64 os=linux pid=14703 revision=febb2a09 version=15.0.0

Check and remove all unused containers (both dangling and unreferenced) including volumes.
------------------------------------------------------------------------------------------
Total reclaimed space: 0B

3. 서비스 시작

root@master:~# gitlab-runner start
Runtime platform                                    arch=amd64 os=linux pid=15022 revision=febb2a09 version=15.0.0

 

등록 방법

1. 토큰 취득

Admin > Overview > Runners 메뉴로 이동한다.

 
Register an instance runner 버튼을 클릭하여 Token을 취득한다.

2. GitLab Runner 등록

root@master:~# gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=25522 revision=f761588f version=14.10.1
Running in system-mode.
 
Enter the GitLab instance URL (for example, https://gitlab.com/):
http://master.example.com:8010/
Enter the registration token:
<취득한 토큰 키 입력>
Enter a description for the runner:
[airnd-gitlab-service.hanpda.com]:
Enter tags for the runner (comma-separated):
 
Enter optional maintenance note for the runner:  Registering runner... succeeded                     runner=y7aWotzg
Enter an executor: custom, parallels, docker+machine, docker-ssh+machine, virtualbox, kubernetes, docker, docker-ssh, shell, ssh:
docker
Enter the default Docker image (for example, ruby:2.7):
centos:7

3. Execute Docker일 경우

생성된 Runner 설정 파일에서 다음과 같이 옵션을 수정해준다.

  • privileged = true (runner가 docker를 실행하려면 priviliged 권한이 필요함. gitlab-ci.yml 사용을 위함)
  • network_mode = "host"
  • volumes = ["/cache","/var/run/docker.sock:/var/run/docker.sock"]
  • pull_policy = "always"
root@master:~# vi /etc/gitlab-runner/config.toml
 
...
[[runners]]
  name = "gitlab.com"
  url = "https://gitlab.com/"
  token = "<토큰>"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "centos:7"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache","/var/run/docker.sock:/var/run/docker.sock"]
    network_mode = "host"
    pull_policy = "always"
    shm_size = 0
...

4. 확인

 

728x90
반응형