简体   繁体   English

Gitlab Runner注册失败

[英]Gitlab Runner Failed to register

I have a gitlab instance with a public IP set up and running.我有一个 gitlab 实例,设置并运行了一个公共 IP。 However, trying to add a gitlab-runner fails, because the reverse lookup for the runner does not seem to work as intended.但是,尝试添加 gitlab-runner 失败,因为对 runner 的反向查找似乎没有按预期工作。 When registering the runner, I can see an incoming POST request with HTTP status 200 on nginx on the gitlab instance注册跑步者时,我可以在 gitlab 实例的 nginx 上看到 HTTP 状态为 200 的传入 POST 请求

1.2.3.4 - - [09/Oct/2021:21:41:51 +0200] "POST /api/v4/runners HTTP/1.1" 200 179 "-" "gitlab-runner 14.3.2 (14-3-stable; go1.13.8; linux/amd64)"

but the runner registration fails.但跑步者注册失败。

 sudo gitlab-runner --debug register --non-interactive --url https://gitlab.example.org/ --registration-token asdasdasdasd --executor shell --tag-list shared --run-untagged=true --locked=false --access-level=not_protected
Runtime platform                                    arch=amd64 os=linux pid=2488 revision=e0218c92 version=14.3.2
Checking runtime mode                               GOOS=linux uid=0
Running in system-mode.                            
                                                   
Dialing: tcp gitlab.example.org:443 ...         
ERROR: Registering runner... failed                 runner=LQ_-Gq-k status=200 OK
PANIC: Failed to register the runner. You may be having network problems. 

The message is a bit misleading...该消息有点误导...

How to show what happens in gitlab after the connection was made?如何显示建立连接后 gitlab 发生了什么? I mean the HTTP response is officially a 200.我的意思是 HTTP 响应正式为 200。

The runner runs behind a NAT and has no public IP, but the gitlab instance has.跑步者在 NAT 后面运行并且没有公共 IP,但 gitlab 实例有。 The route and DNS settings are working to be able to resolve the runner.路线和 DNS 设置正在努力解决跑步者问题。

Gitlab runs behind an Nginx reverse proxy, but the proxy is not controlled by gitlab-ctl . Gitlab 运行在 Nginx 反向代理之后,但该代理不受gitlab-ctl控制。 Since this was a fresh install, I checked my vhost definition and figured that it may be the case, because the incoming requests to register seemed to be eaten by nginx somehow.由于这是全新安装,我检查了我的 vhost 定义并认为可能是这种情况,因为传入的注册请求似乎以某种方式被 nginx 吃掉了。 gitlab-ctl tail did not even log the incoming request to register the runner. gitlab-ctl tail甚至没有记录注册跑步者的传入请求。

With that assumption, I enabled the nginx shipped with gitlab in gitlab.rb有了这个假设,我在gitlab.rb启用了 gitlab 附带的 nginx

nginx['enable'] = true

and ran gitlab-ctl reconfigure just to disable nginx in gitlab.rb afterwards然后运行gitlab-ctl reconfigure只是为了在gitlab.rb禁用 nginx

nginx['enable'] = false

and run gitlab-ctl reconfigure again.并再次运行gitlab-ctl reconfigure

After that procedure, nginx configs are in /var/opt/gitlab/nginx/conf/ .在该过程之后,nginx 配置位于/var/opt/gitlab/nginx/conf/ I replaced my vhost definition with gitlab-http.conf and adapted it further.我用gitlab-http.conf替换了我的 vhost 定义并进一步调整了它。

Now it all works as intended.现在一切都按预期工作了。 My vhost template was completely outdated.我的 vhost 模板已经完全过时了。

I use the ddns, so that you need to resolve the domain name by editing the hosts file, in my case is ubuntu:我使用的是ddns,所以你需要通过编辑hosts文件来解析域名,在我的例子中是ubuntu:

/etc/hosts

add the ip address of your gitlab server ip, like this:添加您的 gitlab 服务器 ip 的 ip 地址,如下所示:

192.168.2.180  yourgitlab.yourdomain.com

then, execute the gitlab-runner register again, it should be successful.然后,再次执行gitlab-runner register,应该就可以成功了。

sudo gitlab-runner register --url https://<yourgitlab.yourdomain.com> --registration-token <your token>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM