alexus
July 12, 2022, 2:32am
#1
Hello World!
I'm trying to configure the health check for the Traefik :
Traefik Ping Documentation - Traefik
Traefik Services Documentation - Traefik
So, I was able to configure health check for the service, but the to check for the health of my Traefik instances, not so much:
/ # traefik healthcheck
Error calling healthcheck: please enable `ping` to use health check
/ # traefik healthcheck --ping
INFO[0000] Configuration loaded from flags.
Bad healthcheck status: 404 Not Found
/ #
relevant options I used for Traefik to start up:
# grep ping docker-compose.yml
- "--entryPoints.ping.address=:8082"
- "--ping=true"
- "--ping.entryPoint=ping"
#
Please advise.
Thank you in advance)
Hello @alexus ,
What are you trying to achieve?
I've used the --ping
CLI argument.
- '--log.level=${TRAEFIK_LOG_LEVEL:-ERROR}'
- '--metrics.prometheus'
# Misc
- '--api.dashboard'
- '--entrypoints.websecure.http.middlewares=compress@file,headers@file${TRAEFIK_PLUGINS:-}'
- '--experimental.plugins.fail2ban.modulename=github.com/tommoulard/fail2ban'
- '--experimental.plugins.fail2ban.version=v0.6.0'
- '--global.checknewversion=${TRAEFIK_CHECK_NEW_VERSION:-false}'
- '--global.sendanonymoususage=${TRAEFIK_SEND_ANONYMOUS_USAGE:-false}'
- '--pilot.token=${TRAEFIK_PILOT_TOKEN:-}'
- '--ping'
- '--providers.file.directory=/dynamic_conf/'
- '--providers.file.watch=true'
ports:
- '${TRAEFIK_WEB_ENTRYPOINT:-80}:${TRAEFIK_WEB_ENTRYPOINT:-80}'
- '${TRAEFIK_WEBSECURE_ENTRYPOINT:-443}:${TRAEFIK_WEBSECURE_ENTRYPOINT:-443}'
networks:
- 'srv'
restart: always
healthcheck:
test: ['CMD', 'traefik', 'healthcheck', '--ping']
And a docker health check.
healthcheck:
test: ['CMD', 'traefik', 'healthcheck', '--ping']
interval: 10s
timeout: 10s
retries: 5
It correctly gets Traefik's health status.
If you want a more streamlined example, take a look at that:
version: '3.9'
services:
traefik:
image: traefik:v2.8
command:
- --ping
healthcheck:
test: ['CMD', 'traefik', 'healthcheck', '--ping']
volumes:
- /var/run/docker.sock:/var/run/docker.sock
alexus
July 12, 2022, 2:49pm
#3
@tommoulard thank you for taking your time reply to my topic, i do appreciate that
the last example is very similar to the one I post initially w/ my topic along side with the output from it, and as you see it's not working( and I can't figure out what's wrong...
For me, my example is working as expected:
$ # I'm using the same docker-compose.yml file
$ docker compose up -d
[+] Running 2/2
⠿ Network test_default Created 0.0s
⠿ Container test-traefik-1 Started 0.5s
$ docker compose ps
NAME COMMAND SERVICE STATUS PORTS
test-traefik-1 "/entrypoint.sh --pi…" traefik running (starting) 80/tcp
$ sleep 10s
$ docker compose ps
NAME COMMAND SERVICE STATUS PORTS
test-traefik-1 "/entrypoint.sh --pi…" traefik running (healthy) 80/tcp
$ docker compose exec traefik traefik healthcheck --ping
INFO[0000] Configuration loaded from flags.
OK: http://:8080/ping
As you can see, the status goes from starting
to healthy
, and the CLI tool is working as expected.
alexus
July 12, 2022, 3:56pm
#5
hmm, it worked for me ...
# docker compose exec traefik traefik healthcheck --ping
WARN[0000] network default: network.external.name is deprecated in favor of network.name
INFO[0000] Configuration loaded from flags.
OK: http://:8080/ping
#
.. once I've made some changes per your example:
# grep ping docker-compose.yml
#- "--entryPoints.ping.address=:8082"
- "--ping=true"
#- "--ping.entryPoint=ping"
#
I believe the issue is in the URL itself, as my ping was suppose to hit port 8082 , however per output it is hitting port 8080 instead..