Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

feat: configure default-network-opts mtu #229

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,19 @@ this value.
**Please note:** This value can cause strange network issues if not configured
properly.

```yaml
gitlab_runner_set_default_network_opts: false
```

This variable enables the declaration of
[`default-network-opts`](https://docs.docker.com/engine/reference/commandline/dockerd/#default-network-options)
in the Docker daemon configuration options.
This helps to prevent docker-compose to create networks with an MTU of 1500,
even though a lower MTU is required.
With this change a user should not be required to set the MTU
on their own in docker-compose files.
Requires at least Docker 24.

```yaml
gitlab_runner_ssh_public_key: "./files/id_ed25519.pub"
gitlab_runner_ssh_private_key: "./files/id_ed25519"
Expand Down
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ gitlab_runner_namerservers:

gitlab_runner_mtu: 1450

gitlab_runner_set_default_network_opts: false

gitlab_runner_config_path: "/etc/gitlab-runner/config.toml"

gitlab_runner_listen_address: ""
Expand Down
1 change: 1 addition & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ provisioner:
gitlab_runner_ssh_private_key: ""
gitlab_runner_registry_mirror: "https://registry-mirror.example"
gitlab_runner_listen_address: "127.0.0.1:9252"
gitlab_runner_set_default_network_opts: true
gitlab_runner_list:
- name: "test01"
url: "https://gitlab.com"
Expand Down
11 changes: 9 additions & 2 deletions templates/flatcar-linux-config.bu.j2
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ storage:
{% if gitlab_runner_insecure_registries | length > 0 %}
"insecure-registries": {{ gitlab_runner_insecure_registries | to_json }},
{% endif %}
"mtu": {{ gitlab_runner_mtu }}
"mtu": {{ gitlab_runner_mtu }},
{% if gitlab_runner_set_default_network_opts %}
"default-network-opts": {
"bridge": {
"com.docker.network.bridge.mtu": "{{ gitlab_runner_mtu }}"
}
}
{% endif %}
}
- path: /etc/flatcar/update.conf
overwrite: true
Expand All @@ -54,7 +61,7 @@ systemd:
- name: 10-docker-opts.conf
contents: |
[Service]
Environment="DOCKER_OPTS=--mtu={{ gitlab_runner_mtu }}{% if registry_mirrors_list | length > 0 %}{% for registry_mirror in registry_mirrors_list %} --registry-mirror={{ registry_mirror }}{% endfor %}{% endif %}"
Environment="DOCKER_OPTS=--mtu={{ gitlab_runner_mtu }} {% if gitlab_runner_set_default_network_opts %}--default-network-opt bridge=com.docker.network.bridge.mtu={{ gitlab_runner_mtu }}{% endif %}{% if registry_mirrors_list | length > 0 %}{% for registry_mirror in registry_mirrors_list %} --registry-mirror={{ registry_mirror }}{% endfor %}{% endif %}"
- name: binfmt-init.service
enabled: true
contents: |
Expand Down
Loading