Repo-Url: https://gitlab.com/strowi/varnish
Should be available on docker and gitlab:
- Varnish 6.0.8
- Varnish-Modules
- libvmod-re
- varnish-exporter 1.6 listening on Port
9131
. - varnish_reload.sh: script to reload varnish-config
- be_state.sh: simple script to change backend-status (uses grep to find backend)
- varnishtop_metrics.sh: export top backend requests as prometheus metrics (node-exporter/textfile)
Opposed to other solutions the varnish-exporter is run in a separate
container sharing /var/lib/varnish
.
You can export variables that will be used to start varnish:
BIND_PORT
- port to bind toVCL_CONFIG
- varnish config file to startVARNISHD_PARAMS
- any additional parameter
This will start the docker-entrypoint.sh:
/usr/sbin/varnishd -P /var/run/varnishd.pid \
-F \
-a $BIND_PORT \
-f $VCL_CONFIG \
-s malloc,$CACHE_SIZE \
$VARNISHD_PARAMS
Example: (docker-compose.yml)[./docker-compose.yml]
Usually you don't want to restart the whole container for updates of the varnish-config because you would empty out the cache.
So we decided to create a separate folder for the configuration, sync that to the mounted ./src
-folder.
And then just run the following to reload the config:
~> docker-compose exec -T varnish varnish_reload.sh -m0 /etc/varnish/default.vcl
Since above varnish_reload.sh
appends a timestamp to the config-name each backends name changes with a config-reload:
> varnishadm backend.list
Backend name Admin Probe Last updated
reload_20210105_104634.backend1 probe Healthy 3/3 Tue, 05 Jan 2021 10:46:38 GMT
reload_20210105_104634.backend2 probe Healthy 3/3 Tue, 05 Jan 2021 10:46:38 GMT
reload_20210105_104634.backend3 probe Healthy 3/3 Tue, 05 Jan 2021 10:46:38 GMT
This can get very annoying when you need to disable single backends. On multiple server even more so.
So be_state.sh
takes a host and a status as argument and greps for the host settings the status.
~> be_state.sh backend1 sick
# looking for backend containing backend1
reload_20210105_104634.backend1
# setting varnish-backend on to sick
~> varnishadm. backend.list
Backend name Admin Probe Last updated
reload_20210105_104634.backend1 probe sick 3/3 Tue, 05 Jan 2021 10:46:38 GMT