https://github.com/kazhuravlev/healthcheck
Readiness probes for Kubernetes application
https://github.com/kazhuravlev/healthcheck
go golang k8s kubernetes readiness readiness-probe
Last synced: about 1 year ago
JSON representation
Readiness probes for Kubernetes application
- Host: GitHub
- URL: https://github.com/kazhuravlev/healthcheck
- Owner: kazhuravlev
- License: mit
- Created: 2024-06-08T15:59:45.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-17T21:13:42.000Z (over 1 year ago)
- Last Synced: 2025-04-10T06:15:50.680Z (about 1 year ago)
- Topics: go, golang, k8s, kubernetes, readiness, readiness-probe
- Language: Go
- Homepage:
- Size: 85.9 KB
- Stars: 13
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go-with-stars - healthcheck - 02-15 | (Utilities / Utility/Miscellaneous)
- awesome-go - healthcheck - A simple yet powerful readiness test for Kubernetes. (Utilities / Utility/Miscellaneous)
- awesome-go - kazhuravlev/healthcheck
- awesome-go-cn - healthcheck
- fucking-awesome-go - healthcheck - A simple yet powerful readiness test for Kubernetes. (Utilities / Utility/Miscellaneous)
- awesome-go-cn - healthcheck
README
# Healthcheck for go applications
[](https://pkg.go.dev/github.com/kazhuravlev/healthcheck)
[](https://github.com/kazhuravlev/healthcheck/blob/master/LICENSE)
[](https://github.com/kazhuravlev/healthcheck/actions/workflows/tests.yml)
[](https://goreportcard.com/report/github.com/kazhuravlev/healthcheck)
[](https://codecov.io/gh/kazhuravlev/healthcheck)
This tools allow you to unlock the kubernetes
feature [Liveness and Readiness](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/).
## Features
- Logger to log failed probes
- Automatic, manual and background checks
- Respond with all healthchecks status in JSON format
- Callback for integrate with metrics or other systems
- Integrated web server
## Quickstart
```shell
go get -u github.com/kazhuravlev/healthcheck
```
Check an [examples](./examples/example.go).
```go
package main
import (
"context"
"errors"
"math/rand"
"time"
"github.com/kazhuravlev/healthcheck"
)
func main() {
ctx := context.TODO()
// 1. Init healthcheck instance. It will store all our checks.
hc, _ := healthcheck.New()
// 2. Register checks that will random respond with an error.
hc.Register(ctx, healthcheck.NewBasic("redis", time.Second, func(ctx context.Context) error {
if rand.Float64() > 0.5 {
return errors.New("service is not available")
}
return nil
}))
// 3. Init and run a webserver for integration with Kubernetes.
sysServer, _ := healthcheck.NewServer(hc, healthcheck.WithPort(8080))
_ = sysServer.Run(ctx)
// 4. Open http://localhost:8080/ready to check the status of your system
select {}
}
```