仅具有内部网络的 VM 上的 GitLab Runner

GitLab Runner on VM with internal network only

我是 运行 来自官方 jetstack helm chart 的 GitLab 实例,位于 Google 云中我的 GKE 集群上。

我想向我的 VPC 网络添加一个 Windows 虚拟机,它只有内部网络访问权限。

通常您必须针对 GitLab 的 https 地址注册 GitLab runner,这在内部网络中是不可能的。有没有办法通过内部网络针对 GitLab 实例注册 GitLab runner?

GitLab 实例通过 nginx-ingress 控制器发布其 https 资源,该控制器也在该 GKE 集群上 运行。

有没有办法使用监听端口 8080 的内部 IP 注册 gitlab-unicorn pod?

提前致谢!

有两种选择:

  • clone_url 如果 runner 可以访问 Gitlab 实例,但它的名称与解析名称不同
  • ssh-tunnel 如果运行者不能直接访问 Gitlab 实例

clone_url

如果您的 gitlab 可以从内部网络访问,您可以使用 clone_url 选项

documentation:

How clone_url works

In cases where the GitLab instance is exposed to an URL which can’t be used by the runner, a clone_url can be configured. For example; GitLab is exposed to https://gitlab.example.com, but the runner can’t reach that because of a firewall setup. If the runner can reach the node on 192.168.1.23, the clone_url should be set to "http://192.168.1.23.

Only if the clone_url is set, the runner will construct a clone URL in the form of http://gitlab-ci-token:s3cr3tt0k3n@192.168.1.23/namespace/project.git

ssh-tunnel

如果您的 Gitlab 实例没有任何可用地址,您可以为它设置 ssh-tunnel

SSH Tunneling is a method of transporting arbitrary networking data over an encrypted SSH connection. It can be used to add encryption to legacy applications. It can also be used to implement VPNs (Virtual Private Networks) and access intranet services across firewalls.

ssh -L 8080:gitlab.yourinstance.com:80 gw.yourgateway.com

然后您可以使用 gw.yourgateway.com:8080 作为您的 clone_url