无法在本地网络服务器上注册Git Runner

5
我正在尝试在公司的本地网络服务器上注册一个Git Runner,GitLab与自签名证书正常工作,但是尝试像这样注册Git Runner时:
sudo gitlab-runner register --tls-ca-file=/home/gitlab-runner/certs/git.crt

粘贴git的URL

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/)
https://git.mycompany/

然后是令牌:

Please enter the gitlab-ci token for this runner: 
TOKEN

然后是描述和标签,然后我遇到了这个错误:

ERROR: Registering runner... failed   
runner=TOKEN status=couldn't execute POST against https://git.mycompany/api/v4/runners:
Post https://git.mycompany/api/v4/runners: 
dial tcp: lookup git.mycompany on 127.0.0.53:53: 
no such host
PANIC: Failed to register this runner. Perhaps you are having network problems

我没有使用Docker,只是普通的设置,请提供任何帮助,非常感谢。

enter image description here

更新:

我将DNS服务器的名称服务器添加到/ etc / resolv.conf中,最后一个错误消失了,但我有新的错误:

 x509: certificate has expired or is not yet valid

即使我使用.crt文件注册runner,如文档所述,并且使用

进行注册。
sudo gitlab-runner register --tls-ca-file /path/to/some-host-gitlab.com.crt

这是自签名证书

enter image description here

更新

如果是自签名证书,那么从2019年6月5日至2019年7月5日有效的证书是否重要?

enter image description here


查询 127.0.0.53:53 上的 git.mycompany - 看起来你正在运行 dnsmasq 或其他本地解析器,并且系统已配置为使用它作为名称服务器。这与 GitLab Runner 无关。您需要修复您的本地 DNS 配置。 - Jonathon Reinhart
3个回答

4
关于DNS问题,您需要在/etc/resolv.conf中更改DNS服务器,并将nameserver设置为你的DNS。
对于证书,GitLab Runner默认检查系统证书存储库,并根据系统中存储的CA验证GitLab服务器。要将您的证书添加到系统中,请将可信证书添加到 /usr/local/share/ca-certificates/,并执行sudo update-ca-certificates命令进行更新。或者,在注册Runner时,您可以将该证书设置为参数--tls-ca-file
我建议您创建一个具有更多验证天数的新证书。(不要忘记在apache2或ngix的GitLab配置中更改证书路径。)

2

看起来是名称解析问题。您能否验证 DNS 服务器的可达性?

从日志中可以看到它正在尝试从主机本身解析。

拨号 TCP:**在 **127.0.0.53:53 上查找 git.mycompany:**** 没有这样的主机


嗨@jobina,我可以通过git.mycompany打开Git,还可以ping。 - Fadi
你已经查看了这些文档吗?https://docs.gitlab.com/runner/configuration/tls-self-signed.html以及https://gitlab.com/gitlab-org/gitlab-runner/blob/master/docs/configuration/advanced-configuration.md - Jobin James
是的,但您有什么特定的要求需要我查看吗? - Fadi
请将CA证书添加到服务器信任存储中。openssl x509 -in /usr/local/share/ca-certificates/ca.pem -inform PEM -out /usr/local/share/ca-certificates/ca.crt并更新CA证书。 - Jobin James
https://dev59.com/3lcP5IYBdhLWcg3wa5I3 - Jobin James

2
针对你最后的更改关于证书的问题: 为了保护连接,Runner将验证你的自签名证书。在证书中具有有效日期是第一步,但Runner仍会拒绝验证自签名证书。因此,我建议你阅读这个问题的讨论:https://gitlab.com/gitlab-org/gitlab-runner/issues/1754 你可以将自签名证书放入PEM文件中,并按照https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/configuration/tls-self-signed.md提供给GitLab Runner。还有一个tls-skip-verify选项:https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/configuration/advanced-configuration.md

嗨,@William,我没有使用Docker,只是使用Shell,并且非Docker运行程序中没有tls-skip-verify选项。我已经尝试添加PEM文件并将其提供给GitLab Runner。 - Fadi

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