healthchecker

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 8 Imported by: 0

README

Health Checker

Build Status Release Status Repo size Image size Docker Pulls

Overview

Health Checker is a Lightweight Utility for HTTP Health Checks in Distroless Docker Environments.

Motivation

The utility provides a HEALTHCHECK mechanism in distroless Docker images.
Distroless images lack a shell, making standard health checks challenging; Health Checker addresses this gap.

How It Works

Health Checker sends HTTP requests to a specified target URL and assesses the responses against expected status codes set by the user.
It supports configuration via both command-line flags and environment variables.

Installation

Download the appropriate binary for your operating system from the GitHub Releases page.

Usage

Run the healthchecker binary with desired flags, or set the environment variables before starting the utility.

Options

Flag Environment Variable Description Default Value
-url HC_URL Target URL for health check http://localhost:80
-status HC_EXPECTED_STATUS_CODE Expected HTTP status code from target 200
-timeout HC_TIMEOUT Request timeout duration 2s

Examples:

CLI:
# With flags
healthchecker -url=http://localhost:80 -status=200 -timeout=2s

# With environment variables
export HC_URL=http://localhost:80
export HC_EXPECTED_STATUS_CODE=200
export HC_TIMEOUT=2s
healthchecker
Docker
docker run braveokafor/healthchecker:latest -url=http://localhost:80 -status=200 -timeout=2s
Dockerfile:
FROM golang:1.21 as build

WORKDIR /go/src/app
COPY . .

RUN go mod download
RUN go vet -v
RUN go test -v

RUN CGO_ENABLED=0 go build -o /go/bin/app


FROM cgr.dev/chainguard/static:latest
USER nobody

COPY --from=build /go/bin/app /
COPY --from=braveokafor/healthchecker:latest /usr/local/bin/healthchecker /healthchecker

EXPOSE 5000

# Healthcheck setup
HEALTHCHECK --interval=10s --timeout=2s --start-period=5s --retries=3 \
    CMD ["/healthchecker", "-url", "http://localhost:5000/healthz", "-status", "200", "-timeout", "2s"] || exit 1

CMD ["/app"]

Contributing

Contributions and suggestions are welcome.
Please open an issue for discussion or propose improvements directly through a pull request.

Support & Issues

Issues Issues

For support or reporting issues, please open an issue in the GitHub repository or reach out on LinkedIn.

License

Health Checker is under the MIT License.
Feel free to use, modify, and distribute the code per the terms of the license.

Need Assistance?

For questions or further assistance, kindly open an issue.

Thank you for using Health Checker!

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL