This repository contains a small Go application used as a readiness probe, serving HTTP responses to signal readiness and termination status.
- Serves a
200 OKresponse on/healthzby default. - Responds with a
410 GONEstatus on/healthzupon receiving aSIGTERMsignal or a manual shutdown request at/stop. - Configurable port via command-line parameter.
- Docker
- Go 1.23+ (if building manually)
-
Build the Docker Image
docker build -t readiness-probe . -
Run the Docker Container
docker run -p 8000:8000 readiness-probe
The application will listen on port 8000 by default. You can map this port or change it using
-p.
-p: Sets the port for the server (default: 8000).-h: Displays help for available flags.
Example to run on a custom port:
readiness_probe -p 8080The Dockerfile is multi-stage:
- Build Stage - Compiles the Go application.
- Final Stage - Copies the built binary into a minimal Alpine image, creating a lightweight container.
The application runs as a non-root user for added security.
- /healthz: Returns
200 OKif healthy,410 GONEif marked as terminated. - /stop: Sets the application to return
410 GONEfor/healthz, emulating a graceful shutdown.
Retrieve the container ID and stop it with SIGTERM:
container_id=$(docker ps -qf "ancestor=readiness-probe")
docker kill -s SIGTERM "$container_id"