Skip to content

Commit a555f4d

Browse files
authored
Update gitlab_ci_demo.md
1 parent e2f4662 commit a555f4d

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

05_testing_and_ci/gitlab_ci_demo.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,44 @@ Test code in [automation lecture repository](https://gitlab-sim.informatik.uni-s
3131

3232
You can get the IP from the [Instances view](https://portal.bw-cloud.org/project/instances/). Note that there are two addresses here: an IPv4 (decimal) and an IPv6 (hexadecimal) address. New VMs on bwCloud only support IPv6 networks, so you need the second address.
3333

34+
## Workarounds for IPv6
35+
36+
New bwCloud VMs only support IPv6 by default. Asking for IPv4 for a specific VM might be possible via the [helpdesk](https://bw-cloud.org/q/t).
37+
38+
A few workarounds are needed to make the GitLab runner work in this IPv6-only environment, especially since [`registry.gitlab.com` does not support IPv6](https://gitlab.com/gitlab-com/gl-infra/production-engineering/-/issues/18058) and the Docker support for IPv6 needs to be expliticly configured.
39+
40+
First, we need to tell Docker to use the host network and DNS. We also need to replace the helper image with [the one from Docker Hub](https://hub.docker.com/r/gitlab/gitlab-runner-helper/tags?name=x86_64-v17.10.1). Edit the `[runners.docker]` section in `/srv/gitlab-runner/config/config.toml`:
41+
42+
```toml
43+
volumes = ["/etc/resolv.conf:/etc/resolv.conf:ro", "/srv/gitlab-runner/custom-hosts:/etc/hosts:ro", "/cache"]
44+
helper_image = "gitlab/gitlab-runner-helper:x86_64-v17.10.1"
45+
network_mode = "host"
46+
```
47+
48+
While you could pass `--network host` to `docker run`, setting this system-wide makes it easier to also start the job containers with the same settings.
49+
50+
Whenever changing this configuration file, we need to restart the runner (e.g., by restarting the respective container).
51+
52+
We also need to hard-code the IPv6 address that corresponds to the GitLab instance domain. Add the following line in the `/srv/gitlab-runner/custom-hosts`:
53+
54+
```
55+
2001:7c0:2015:216::19 gitlab-sim.informatik.uni-stuttgart.de
56+
```
57+
58+
You can get this address by running `dig aaaa gitlab-sim.informatik.uni-stuttgart.de`.
59+
3460
## Setup GitLab Runner
3561

3662
- Install GitLab Runner via Docker:
3763

3864
```bash
3965
sudo docker run -d --name gitlab-runner --restart always \
40-
--network host \
4166
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
4267
-v /var/run/docker.sock:/var/run/docker.sock \
4368
gitlab/gitlab-runner:latest
4469
```
4570

4671
- `docker run -d --name gitlab-runner --restart always` runs the container in the background (`-d` means detached) names it `gitlab-runner` and makes sure that it always runs. The container is automatically restarted once it stops/crashes. If you want to stop the container, you have to stop it manually (`docker container stop`).
47-
- `--network host` tells Docker to use the host network stack and is needed on bwCloud VMs, which only support IPv6.
4872
- `-v /srv/gitlab-runner/config:/etc/gitlab-runner` mounts the directory `/srv/gitlab-runner/config` into the container.
4973
- `-v /var/run/docker.sock:/var/run/docker.sock` mounts important Docker files into the container such that the container can start other containers (for pipelines).
5074
- `gitlab/gitlab-runner:latest` is the GitLab Runner image used from Docker Hub.
@@ -60,7 +84,6 @@ You can register a runner using the following command. Notice again the `--netwo
6084

6185
```bash
6286
sudo docker run --rm -it \
63-
--network host \
6487
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
6588
gitlab/gitlab-runner register \
6689
--url https://gitlab-sim.informatik.uni-stuttgart.de/

0 commit comments

Comments
 (0)