启动runner容器命令:

sudo docker run -d --name gitlab-runner-portal2 --restart always  -v /srv/gitlab-runner/portal2:/etc/gitlab-runner -v /etc/hosts:/etc/hosts  -v /var/run/docker.sock:/var/run/docker.sock registry-inc.xxx:5000/gitlab/gitlab-runner:v1

查看runner信息:

[l-yourname@test02 ~]$ sudo docker ps -a| grep runner

更新runner:

gitlab-runner stop
curl -o /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-amd64
chmod +x /usr/local/bin/gitlab-runner
gitlab-runner start

注册runner:

[l-yourname@test02 ~]$ sudo docker exec -it gitlab-runner-portal2 /bin/bash
root@fa49cf872ad7:/# gitlab-ci-multi-runner register
Runtime platform                                    arch=amd64 os=linux pid=39 revision=6d480948 version=15.7.1
Running in system-mode.
Enter the GitLab instance URL (for example, https://gitlab.com/):
https://gitlab.xxx/
Enter the registration token:
6S9y3zT2tC5VtA5RMJxH
Enter a description for the runner:
[fa49cf872ad7]: yourname test
Enter tags for the runner (comma-separated):
gitlab-ci-runner-k8s,portal-runner
Enter optional maintenance note for the runner:
ysp test my own comman
WARNING: Support for registration tokens and runner parameters in the 'register' command has been deprecated in GitLab Runner 15.6 and will be replaced with support for authentication tokens. For more information, see https://gitlab.com/gitlab-org/gitlab/-/issues/380872
Registering runner... succeeded                     runner=6S9y3zT2
Enter an executor: docker+machine, kubernetes, custom, docker, docker-ssh, parallels, shell, ssh, virtualbox, docker-ssh+machine, instance:
docker
Enter the default Docker image (for example, ruby:2.7):
centos:7
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
Configuration (with the authentication token) was saved in "/etc/gitlab-runner/config.toml"
root@fa49cf872ad7:/#

配置文件:

宿主机配置映射路径:sudo vi /srv/gitlab-runner/portal2/config.toml
root@19f168a4da76:/# cat  /etc/gitlab-runner/config.toml
concurrent = 1
check_interval = 0
shutdown_timeout = 0
[session_server]
  session_timeout = 1800
  
[[runners]]
  name = "asm-web-portal-api"
  url = "https://gitlab.xxx/"
  id = 87
  token = "Ect3NN26pPceG8Ncay6B"
  token_obtained_at = 2024-07-23T02:25:44Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    MaxUploadedArchiveSize = 0
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "docker:20.10.13"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    extra_hosts = ["gitlab.xxx:10.95.58.68"]
    allowed_pull_policies = ["if-not-present"]
    pull_policy = ["if-not-present"]
    shm_size = 0

查看docker运行runner的配置:

[l-yourname@test02 ~]$ sudo docker inspect gitlab-runner-portal2

由此推测原始命令:

sudo docker run -d  --name gitlab-runner-portal3  -v /srv/gitlab-runner/portal3:/etc/gitlab-runner  -v /etc/hosts:/etc/hosts  -v /var/run/docker.sock:/var/run/docker.sock  registry-inc.xxx:5000/gitlab/gitlab-runner:v1  run --user=gitlab-runner --working-directory=/home/gitlab-runner  --restart always
与实际相比有一些区别,但是大部分正确的。
所有用户都可以去薅羊毛,192元充值200元话费!先到先得!导航栏话费充值,正规可靠,快充慢充自由选择。
欧阳逸资源站 » gitlab-ci runner部署

发表评论