| Crates.io | http-envinfo |
| lib.rs | http-envinfo |
| version | 0.1.0 |
| created_at | 2025-01-06 17:38:04.79945+00 |
| updated_at | 2025-01-06 17:38:04.79945+00 |
| description | This package provides JSON API of health for microservice. It's using rocket framework. |
| homepage | |
| repository | https://gitlab.com/tech-engineering/rocket-health-probes |
| max_upload_size | |
| id | 1505925 |
| size | 70,851 |
EnvInfo is an open-source project. This goal is to provide a very small micro-service which display the execution environment in a JSON on the HTTP protocol.
It is written in the Rust language with the Rocket framework and offers a container image for using in a Kubernetes cluster, for example.
Below, find the instruction for localy rebuild the project and create a container image (based on docker runtime). Else, the current docker image is provide in gitlab registry registry.gitlab.com/tech-engineering/tools/envinfo.
Build source code:
cargo build
And run the source code, run http server on port 8000:
ROCKET_PROFILE=debug cargo run
Test with httpie:
http http://127.0.0.1:8000
Build image for two platform CPU architecture (amd64 and arm64):
docker buildx build \
--push \
--platform linux/amd64,linux/arm64 \
-t envinfo:v0.1-test \
-f Dockerfile.alpine .
docker run --rm --name info -p 8080:8080 \
-d envinfo:v0.1-test
Remark: The port and address allow are configured for 0.0.0.0 on 8080.
Test the endpoints (with httpie):
http http://localhost:8080
http http://localhost:8080/health
http http://localhost:8080/health/ready
http http://localhost:8080/health/alive
http http://localhost:8080/health/started
The microservice implemented 4 endpoints:
/health/alive/health/ready/health/started/healthThese endpoints respond with HTTP status 200 OK on success or 503 Service Unavailable on failure, and a JSON object like the following: Successful response for endpoints without additional per-check information:
{
"status": "UP",
"checks": []
}
Only for /health/started endpoint:
{
"status": "STARTED",
"endpoints": ["/health","/health/alive","/health/ready","/health/started"]
}
The yaml manifest is ready to use. Apply on your cluster:
kubectl apply -f deploy/k8s/envinfo-deploy.yaml
Check it:
kubectl port-forward svc/envinfo-svc --address 0.0.0.0 80:8080
Test the endpoints (with httpie):
http http://localhost
http http://localhost/health
http http://localhost/health/ready
http http://localhost/health/alive
http http://localhost/health/started
Example, hostname of container:
http http://localhost | jq ".hostname"
or distro:
http http://localhost | jq ".distro"
or ip:
http http://localhost | jq ".net_interface.[].ip"
or name of environment variables:
http http://localhost | jq ".environment.[].name"
Search in particular an environment variable (here ROCKET_ADDRESS):
http http://localhost | jq '.environment.[] | select (.name=="ROCKET_ADDRESS")'
or (only value):
http http://localhost | jq '.environment.[] | select (.name=="ROCKET_ADDRESS")' | jq ".value"
Thanks to participate at this project if you want :)
I need any ideas about what display informations, or other.