Gitlab CI - 注册 runner 失败

5

我已经从源代码设置了我的gitlab安装,并使用letsencrypt进行了保护,然后在https://gitlab.mydomain.com下部署。我可以访问网站并创建存储库等内容,但是我找不到注册gitlab ci runner的方法。

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci):
https://gitlab.mydomain.com/ci
Please enter the gitlab-ci token for this runner:
xxxxxxxx-xxxxxxxx
Please enter the gitlab-ci description for this runner:
[server]: test
Please enter the gitlab-ci tags for this runner (comma separated):
test
ERROR: Registering runner... failed     runner=xxxxxxx 
status=couldn't execute POST against https://gitlab.mydomain.com/ci/api/v1/runners/register.json:
Post https://gitlab.mydomain.com/ci/api/v1/runners/register.json: 
read tcp [ipv6address]:33518->[ipv6address]:443: read: connection reset by peer
PANIC: Failed to register this runner. Perhaps you are having network problems

我的GitLab系统运行良好,但我真的无法解释为什么会出现“连接被对等方重置”的错误。当我尝试直接从错误消息中使用curl访问地址时,它返回了正确的响应。

curl -v https://gitlab.mydomain.com/ci/api/v1/runners/register.json
*   Trying ipv6address...
* Connected to gitlab.mydomain.com (ipv6address) port 443 (#0)
* found 174 certificates in /etc/ssl/certs/ca-certificates.crt
* found 700 certificates in /etc/ssl/certs
* ALPN, offering h2
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_256_GCM_SHA384
*        server certificate verification OK
*        server certificate status verification SKIPPED
*        common name: mydomain.com (matched)
*        server certificate expiration date OK
*        server certificate activation date OK
*        certificate public key: RSA
*        certificate version: #3
*        subject: CN=mydomain.com
*        start date: Wed, 18 May 2016 14:35:00 GMT
*        expire date: Tue, 16 Aug 2016 14:35:00 GMT
*            issuer: C=US,O=Let's Encrypt,CN=Let's Encrypt Authority X3
*        compression: NULL
* ALPN, server did not agree to a protocol
> GET /ci/api/v1/runners/register.json HTTP/1.1
> Host: gitlab.mydomain.com
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 405 Method Not Allowed
< Server: nginx
< Date: Sun, 29 May 2016 09:14:09 GMT
< Content-Type: application/json
< Content-Length: 2
< Connection: keep-alive
< Allow: OPTIONS, POST
< Cache-Control: no-cache
< Status: 405 Method Not Allowed

你能发布一下你的运行配置吗? - Hui Wang
@HuiWang - 它只有一行 concurrent = 1。我猜测这是因为创建配置文件的过程失败了,导致出现了上述错误。 - Jonas
请查看此链接 https://gitlab.com/wiget/gitlab-ci-multi-runner/blob/master/docs/configuration/tls-self-signed.md - Hui Wang
@HuiWang - 我不明白我需要将哪个来自letsencrypt的证书存储在请求的位置。我尝试将我的 fullchain.pem 复制到 /etc/gitlab-runner/gitlab.mydomain.com.crt,但错误仍然发生。当我使用 --debug 时,它说 Trying to load /etc/gitlab-runner/certs/gitlab.mydomain.com.crt ... 但没有更多信息。 - Jonas
5个回答

2
如果Runner和GitLab在同一台主机上运行,您可以通过输入以下内容来解决此问题,而不是使用文档中提供的内容:
http://gitlab:port

这里的gitlab是容器名称,port是容器左侧端口号。如果您在使用gitlab内部的ssl证书,则需要指定https而不是http。每当我遇到此问题时,这种方法总是解决它。


1

对于那些使用Docker的人:

问题与Docker网络有关。

如果你尝试:

  "$docker container inspect $id"

你将看到gitlab容器的IPAddress。
在第一个问题中指向该ip地址以正常工作。

0

我在编程过程中遇到了很多错误和问题,从404错误、403错误一直到post请求出现问题。

对我来说,问题似乎在于GitLab与ci-runner之间的不兼容。

解决方法与post问题相同,安装ci-runner的旧版本:

sudo apt install gitlab-ci-multi-runner=1.11.1


我尝试过了,但仍然无法正常工作,仍然出现错误“ERROR: Registering runner... failed runner=pcT3WTf5 status=couldn't execute POST against http://gitlab.com/api/v4/runners: Post https://gitlab.com:443/api/v4/runners: x509: certificate signed by unknown authority
PANIC: Failed to register this runner. Perhaps you are having network problems”
- Kishore
在您的情况下,看起来是HTTPS和证书问题。使用一些受信任的机构(如Let's Encrypt)或手动添加您用于签署证书的CA作为受信任的机构。这应该有所帮助 https://docs.gitlab.com/runner/configuration/tls-self-signed.html - Jan

0
问题在将gitlab更新到8.8.3和将gitlab-multi-ci-runner更新到最新版本后解决了。
我还从头开始配置了我的gitlab nginx配置文件。
最终,我无法确定哪个更改确切地解决了问题。

0

我通过安装gitlab-ci-multi-runner=1.11.1解决了这个问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接