Commit 14eead82 authored by Tomasz Maczukin's avatar Tomasz Maczukin Committed by Suzanne Selhorn

Update documentation for Kubernetes and DinD case for mirroring

parent 1403076d
...@@ -362,13 +362,13 @@ Kubernetes: ...@@ -362,13 +362,13 @@ Kubernetes:
##### Docker executor inside GitLab Runner configuration ##### Docker executor inside GitLab Runner configuration
If you are an administrator of GitLab Runner and you always want to use If you are an administrator of GitLab Runner and you want to use
the mirror for every `dind` service, update the the mirror for every `dind` service, update the
[configuration](https://docs.gitlab.com/runner/configuration/advanced-configuration.html) [configuration](https://docs.gitlab.com/runner/configuration/advanced-configuration.html)
to specify a [volume to specify a [volume
mount](https://docs.gitlab.com/runner/configuration/advanced-configuration.html#volumes-in-the-runnersdocker-section). mount](https://docs.gitlab.com/runner/configuration/advanced-configuration.html#volumes-in-the-runnersdocker-section).
Given we have a file `/opt/docker/daemon.json` with the following For example, if you have a `/opt/docker/daemon.json` file with the following
content: content:
```json ```json
...@@ -379,7 +379,7 @@ content: ...@@ -379,7 +379,7 @@ content:
} }
``` ```
Update the `config.toml` for GitLab Runner to mount the file to Update the `config.toml` file to mount the file to
`/etc/docker/daemon.json`. This would mount the file for **every** `/etc/docker/daemon.json`. This would mount the file for **every**
container that is created by GitLab Runner. The configuration will be container that is created by GitLab Runner. The configuration will be
picked up by the `dind` service. picked up by the `dind` service.
...@@ -394,7 +394,57 @@ picked up by the `dind` service. ...@@ -394,7 +394,57 @@ picked up by the `dind` service.
volumes = ["/opt/docker/daemon.json:/etc/docker/daemon.json:ro"] volumes = ["/opt/docker/daemon.json:/etc/docker/daemon.json:ro"]
``` ```
### Use Docker socket binding ##### Kubernetes executor inside GitLab Runner configuration
> [Introduced](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/3223) in GitLab Runner 13.6.
If you are an administrator of GitLab Runner and you want to use
the mirror for every `dind` service, update the
[configuration](https://docs.gitlab.com/runner/configuration/advanced-configuration.html)
to specify a [ConfigMap volume
mount](https://docs.gitlab.com/runner/executors/kubernetes.html#using-volumes).
For example, if you have a `/tmp/daemon.json` file with the following
content:
```json
{
"registry-mirrors": [
"https://registry-mirror.example.com"
]
}
```
Create a [ConfigMap](https://kubernetes.io/docs/concepts/configuration/configmap/) with the content
of this file. You can do this with a command like:
```shell
kubectl create configmap docker-daemon --namespace gitlab-runner --from-file /tmp/daemon.json
```
NOTE: **Note:**
Make sure to use the namespace that GitLab Runner Kubernetes executor uses
to create job pods in.
After the ConfigMap is created, you can update the `config.toml`
file to mount the file to `/etc/docker/daemon.json`. This update
mounts the file for **every** container that is created by GitLab Runner.
The configuration is picked up by the `dind` service.
```toml
[[runners]]
...
executor = "kubernetes"
[runners.kubernetes]
image = "alpine:3.12"
privileged = true
[[runners.kubernetes.volumes.config_map]]
name = "docker-daemon"
mount_path = "/etc/docker/daemon.json"
sub_path = "daemon.json"
```
#### Use Docker socket binding
The third approach is to bind-mount `/var/run/docker.sock` into the The third approach is to bind-mount `/var/run/docker.sock` into the
container so that Docker is available in the context of that image. container so that Docker is available in the context of that image.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment