Skip to content

Commit 070dbab

Browse files
authored
GitLab CI demo: Add workaround for IPv6 VMs (#216)
1 parent 7ae2e35 commit 070dbab

File tree

1 file changed

+40
-7
lines changed

1 file changed

+40
-7
lines changed

05_testing_and_ci/gitlab_ci_demo.md

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Test code in [automation lecture repository](https://gitlab-sim.informatik.uni-s
1414
- Edit in pipeline editor -> Visualize
1515
- Settings -> CI/CD -> Runners -> Specific runners
1616
- URL and Token; we will need this in a minute
17+
- Select `Run untagged jobs`
1718

1819
## Inspect bwCloud
1920

@@ -22,24 +23,29 @@ Test code in [automation lecture repository](https://gitlab-sim.informatik.uni-s
2223
- I have already set up a VM. What I did:
2324
- Add public SSH key
2425
- Instances -> Launch instance
25-
- Ubuntu 22.04
26+
- Ubuntu 24.04
2627
- Flavor: m1.small
27-
- `sudo apt update && sudo apt -y upgrade`
28-
- `sudo apt install -y docker.io`
29-
- VM is up and running, connect to it: `ssh ubuntu@<IP>`
28+
- VM is up and running, connect to it: `ssh ubuntu@<IPv6>`
29+
- Apply updates: `sudo apt update && sudo apt -y upgrade`
30+
- Install Docker: `sudo apt install -y docker.io`
31+
32+
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.
3033

3134
## Setup GitLab Runner
3235

3336
- Install GitLab Runner via Docker:
3437

3538
```bash
3639
sudo docker run -d --name gitlab-runner --restart always \
40+
--network host \
41+
-e GODEBUG="netdns=go+ipv6" \
3742
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
3843
-v /var/run/docker.sock:/var/run/docker.sock \
3944
gitlab/gitlab-runner:latest
4045
```
4146

4247
- `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`).
48+
- The `--network host` and `-e GODEBUG="netdns=go+ipv6"` are needed in this IPv6-only VM (see section below).
4349
- `-v /srv/gitlab-runner/config:/etc/gitlab-runner` mounts the directory `/srv/gitlab-runner/config` into the container.
4450
- `-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).
4551
- `gitlab/gitlab-runner:latest` is the GitLab Runner image used from Docker Hub.
@@ -51,10 +57,21 @@ Test code in [automation lecture repository](https://gitlab-sim.informatik.uni-s
5157

5258
## Register Runner
5359

54-
- `sudo docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register`
55-
- URL: `https://gitlab-sim.informatik.uni-stuttgart.de/`
60+
You can register a runner using the following command. Notice again the `--network host` option, which tells Docker to use the host network stack. This is an important workaround for the fact that bwCloud only supports IPv6 networks:
61+
62+
```bash
63+
sudo docker run --rm -it \
64+
--network host \
65+
-e GODEBUG="netdns=go+ipv6" \
66+
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
67+
gitlab/gitlab-runner register \
68+
--url https://gitlab-sim.informatik.uni-stuttgart.de/
69+
```
70+
71+
- Enter the following details:
72+
- URL: (press Enter to confirm)
5673
- Token: see above
57-
- Description: `SSE Automation Demo Runner`
74+
- Name/Description: `SSE Automation Demo Runner`
5875
- No tags, no maintenance note
5976
- Executor: `docker`
6077
- Default Docker image: `alpine:latest` (used for pipelines that do not specify any Docker image themselves, can be overwritten in configuration of pipeline)
@@ -65,3 +82,19 @@ Test code in [automation lecture repository](https://gitlab-sim.informatik.uni-s
6582
- More information:
6683
- [Executors and their abilities](https://docs.gitlab.com/runner/executors/)
6784
- [Registering runners](https://docs.gitlab.com/runner/register/index.html#docker).
85+
86+
## Workarounds for IPv6
87+
88+
New bwCloud VMs only support IPv6 by default. Asking for IPv4 for a specific VM might be possible via the [helpdesk](https://bw-support.scc.kit.edu/). A few workarounds are needed to make the GitLab runner work in this IPv6-only environment.
89+
90+
First, we need to start Docker with `-e GODEBUG="netdns=go+ipv6"`. This is related to Go prioritizing IPv4 connections.
91+
92+
We also need to tell Docker to use the host network stack. 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) (depends on the GitLab version), since [`registry.gitlab.com` does not support IPv6](https://gitlab.com/gitlab-com/gl-infra/production-engineering/-/issues/18058). You can start without this setting, and see which image GitLab is trying to pull). Edit the `[runners.docker]` section in `/srv/gitlab-runner/config/config.toml`:
93+
94+
```toml
95+
helper_image = "gitlab/gitlab-runner-helper:x86_64-v17.10.1"
96+
network_mode = "host"
97+
```
98+
99+
While we already pass `--network host` to `docker run`, setting this system-wide makes it easier to also start the job containers with the same settings.
100+

0 commit comments

Comments
 (0)