{"id":13646475,"url":"https://github.com/vmware-archive/healthcheck","last_synced_at":"2025-04-21T21:30:48.775Z","repository":{"id":42400081,"uuid":"105072316","full_name":"vmware-archive/healthcheck","owner":"vmware-archive","description":"A library for implementing Kubernetes liveness and readiness probe handlers in your Go application.","archived":true,"fork":false,"pushed_at":"2021-11-23T02:54:25.000Z","size":44,"stargazers_count":687,"open_issues_count":17,"forks_count":88,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-08-02T01:26:05.093Z","etag":null,"topics":["healthcheck","kubernetes","liveness","readiness"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vmware-archive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-27T21:41:13.000Z","updated_at":"2024-07-21T06:19:56.000Z","dependencies_parsed_at":"2022-09-10T18:32:19.379Z","dependency_job_id":null,"html_url":"https://github.com/vmware-archive/healthcheck","commit_stats":null,"previous_names":["heptio/healthcheck","heptiolabs/healthcheck"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware-archive%2Fhealthcheck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware-archive%2Fhealthcheck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware-archive%2Fhealthcheck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware-archive%2Fhealthcheck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vmware-archive","download_url":"https://codeload.github.com/vmware-archive/healthcheck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223880204,"owners_count":17219076,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["healthcheck","kubernetes","liveness","readiness"],"created_at":"2024-08-02T01:02:56.875Z","updated_at":"2024-11-09T20:30:15.017Z","avatar_url":"https://github.com/vmware-archive.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# healthcheck\n[![Build Status](https://travis-ci.org/heptiolabs/healthcheck.svg?branch=master)](https://travis-ci.org/heptiolabs/healthcheck)\n[![Go Report Card](https://goreportcard.com/badge/github.com/heptiolabs/healthcheck)](https://goreportcard.com/report/github.com/heptiolabs/healthcheck)\n[![GoDoc](https://godoc.org/github.com/heptiolabs/healthcheck?status.svg)](https://godoc.org/github.com/heptiolabs/healthcheck)\n\nHealthcheck is a library for implementing Kubernetes [liveness and readiness](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/) probe handlers in your Go application.\n\n## Features\n\n - Integrates easily with Kubernetes. This library explicitly separates liveness vs. readiness checks instead of lumping everything into a single category of check.\n\n - Optionally exposes each check as a [Prometheus gauge](https://prometheus.io/docs/concepts/metric_types/#gauge) metric. This allows for cluster-wide monitoring and alerting on individual checks.\n\n - Supports asynchronous checks, which run in a background goroutine at a fixed interval. These are useful for expensive checks that you don't want to add latency to the liveness and readiness endpoints.\n\n - Includes a small library of generically useful checks for validating upstream DNS, TCP, HTTP, and database dependencies as well as checking basic health of the Go runtime.\n\n## Usage\n\nSee the [GoDoc examples](https://godoc.org/github.com/heptiolabs/healthcheck) for more detail.\n\n - Install with `go get` or your favorite Go dependency manager: `go get -u github.com/heptiolabs/healthcheck`\n\n - Import the package: `import \"github.com/heptiolabs/healthcheck\"`\n\n - Create a `healthcheck.Handler`:\n   ```go\n   health := healthcheck.NewHandler()\n   ```\n\n - Configure some application-specific liveness checks (whether the app itself is unhealthy):\n   ```go\n   // Our app is not happy if we've got more than 100 goroutines running.\n   health.AddLivenessCheck(\"goroutine-threshold\", healthcheck.GoroutineCountCheck(100))\n   ```\n\n - Configure some application-specific readiness checks (whether the app is ready to serve requests):\n   ```go\n   // Our app is not ready if we can't resolve our upstream dependency in DNS.\n   health.AddReadinessCheck(\n       \"upstream-dep-dns\",\n       healthcheck.DNSResolveCheck(\"upstream.example.com\", 50*time.Millisecond))\n\n   // Our app is not ready if we can't connect to our database (`var db *sql.DB`) in \u003c1s.\n   health.AddReadinessCheck(\"database\", healthcheck.DatabasePingCheck(db, 1*time.Second))\n   ```\n\n - Expose the `/live` and `/ready` endpoints over HTTP (on port 8086):\n   ```go\n   go http.ListenAndServe(\"0.0.0.0:8086\", health)\n   ```\n\n - Configure your Kubernetes container with HTTP liveness and readiness probes see the ([Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/)) for more detail:\n   ```yaml\n   # this is a bare bones example\n   # copy and paste livenessProbe and readinessProbe as appropriate for your app\n   apiVersion: v1\n   kind: Pod\n   metadata:\n     name: heptio-healthcheck-example\n   spec:\n     containers:\n     - name: liveness\n       image: your-registry/your-container\n\n       # define a liveness probe that checks every 5 seconds, starting after 5 seconds\n       livenessProbe:\n         httpGet:\n           path: /live\n           port: 8086\n         initialDelaySeconds: 5\n         periodSeconds: 5\n\n       # define a readiness probe that checks every 5 seconds\n       readinessProbe:\n         httpGet:\n           path: /ready\n           port: 8086\n         periodSeconds: 5\n   ```\n\n - If one of your readiness checks fails, Kubernetes will stop routing traffic to that pod within a few seconds (depending on `periodSeconds` and other factors).\n\n - If one of your liveness checks fails or your app becomes totally unresponsive, Kubernetes will restart your container.\n\n ## HTTP Endpoints\n When you run `go http.ListenAndServe(\"0.0.0.0:8086\", health)`, two HTTP endpoints are exposed:\n\n  - **`/live`**: liveness endpoint (HTTP 200 if healthy, HTTP 503 if unhealthy)\n  - **`/ready`**: readiness endpoint (HTTP 200 if healthy, HTTP 503 if unhealthy)\n\nPass the `?full=1` query parameter to see the full check results as JSON. These are omitted by default for performance.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmware-archive%2Fhealthcheck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvmware-archive%2Fhealthcheck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmware-archive%2Fhealthcheck/lists"}