Tool to replicate a Purge request to all instances of Varnish in a cluster.
- Docker Compose
- Docker Swarm
Add a new service to a Docker Compose:
purger:
image: ghcr.io/kitconcept/cluster-purger:latest
ports:
- "8000:80"
environment:
PURGER_MODE: "compose"
PURGER_SERVICE_NAME: varnish
PURGER_SERVICE_PORT: 80
PURGER_PUBLIC_SITES: "['site.example.com', 'cms.example.com']"This service exposes port 8000 on the local host (only for debugging purposes), and relies on the existence of another service called varnish.
To purge the /de path on Varnish, from another service in the same compose:
import httpx
response = httpx.request(method="PURGE", url="http://purger/de")To purge the /de path on Varnish, from the host, use:
import httpx
response = httpx.request(method="PURGE", url="http://localhost:8000/de")| Variable | Description | Example | Default |
|---|---|---|---|
| PURGER_MODE | Which type of cluster. Could be compose or swarm |
swarm |
swarm |
| PURGER_SERVICE_NAME | Varnish service name in the cluster | varnish |
|
| PURGER_SERVICE_PORT | Service port | 8080 |
80 |
| PURGER_PUBLIC_SITES | List of public hostnames to send in the Host header | "['site.example.com', 'cms.example.com']" |
This tool has OpenTelemetry support built-in. To use it, set the following environment variables on your service definition.
| Variable | Description | Example |
|---|---|---|
| OTEL_EXPORTER_OTLP_ENDPOINT | OpenTelemetry endpoint | http://192.168.1.1:4317 |
| OTEL_RESOURCE_ATTRIBUTES | Set attributes for OpenTelemetry, i.e. service name | service.name=cluster-purger |
| OTEL_DEBUG | Dump OpenTelemetry traces to console instead of sending it to the server | True |
The project is licensed under MIT License
