Assume that you have a Chartmuseum container running in AWS Fargate.
Chartmuseum is a repository for helm charts. AWS Fargate is an Amazon service to run containers (“serverless”), being part of ECS (Elastic Container Service).
Problem statement: Add a container healthcheck to the chartmuseum task definition associated with the container.
The official
docs
suggest using curl
:
["CMD-SHELL", "curl -f http://localhost/ || exit 1"]
For Chartmuseum specifically we’re interested in its /health
endpoint, as per
this reference:
["CMD-SHELL", "curl -f http://localhost/health || exit 1"]
But we’re using port 8080:
["CMD-SHELL", "curl -f http://localhost:8080/health || exit 1"]
If you use this healthcheck for the official chartmuseum image
(ghcr.io/helm/chartmuseum
) it will fail, because the Alpine Linux environment
it uses does not contain curl
.
A straightforward fix is to use wget
instead:
["CMD-SHELL", "wget -q --spider http://localhost:8080/health || exit 1"]
--spider
is needed because we do not want to download anything, -q
is
optional and short for “quiet”.
The /health
endpoint merely returns a simple JSON:
{"healthy":true}
References: https://stackoverflow.com/questions/47722898/how-can-i-make-a-docker-healthcheck-with-wget-instead-of-curl