Add support for sidecar containers and volumes in Kubernetes backend (#5666)

This commit is contained in:
Martin Schmidt
2025-11-06 16:45:38 +01:00
committed by GitHub
parent 14320372e3
commit 02ea16ecbf
4 changed files with 192 additions and 0 deletions

View File

@@ -283,6 +283,32 @@ backend_options:
In order to enable this configuration you need to set the appropriate environment variables to `true` on the woodpecker agent:
[WOODPECKER_BACKEND_K8S_POD_ANNOTATIONS_ALLOW_FROM_STEP](#backend_k8s_pod_annotations_allow_from_step) and/or [WOODPECKER_BACKEND_K8S_POD_LABELS_ALLOW_FROM_STEP](#backend_k8s_pod_labels_allow_from_step).
### Sidecars
Sidecars allow you to run additional containers alongside your main step container. This is particularly useful for services like Docker-in-Docker (DinD), databases, or other dependencies that need to run during your pipeline step.
#### Docker-in-Docker (DinD) Example
Here's how to configure a sidecar for Docker-in-Docker functionality:
```yaml
steps:
- name: build-with-docker
image: docker:cli
commands:
- docker build -t my-app .
- docker run --rm my-app
backend_options:
kubernetes:
sidecars:
- name: docker-in-docker
image: docker:dind
privileged: true
volumeMounts:
- name: docker-socket
mountPath: /var/run
```
## Tips and tricks
### CRI-O