返回排行榜

kuberhealthy/kuberhealthy

Gokuberhealthy.github.io/kuberhealthy/

A Kubernetes operator for running synthetic checks as pods. Works great with Prometheus!

kuberneteshealthmonitoringsyntheticcicdcontinuous-deliverycontinuous-integrationcontinuous-testingoperator
Star 增长趋势
Star
2.3k
Forks
291
周增长
Issues
7
1k2k
2018年7月2021年3月2023年11月2026年7月
制品库Go Modulesgo get github.com/kuberhealthy/kuberhealthy
README

Kuberhealthy

Kuberhealthy

Kuberhealthy is an operator for synthetic monitoring and continuous validation. It ships metrics to Prometheus and enables you to package your synthetic monitoring as Kubernetes manifests.

License Go Report Card CII Best Practices CI GitHub Release Join Slack

Why Kuberhealthy?

Kuberhealthy schedules, tracks, monitors, and manages Kubernetes pods for checks — which means your monitoring logic can:

  • Run multi-step workflows — simulate a real user: log in, create a record, verify it, clean it up
  • Use any languageGo, Python, Rust, bash, or anything that fits in a container
  • Own your checks as code — checks are Kubernetes manifests, so ship them alongside your app!

How it works

graph TB
    prometheus["Prometheus /metrics"]
    browser["Web Interface"]

    subgraph cluster["Kubernetes Cluster"]
        svc["Kuberhealthy Service :80"]
        crds["HealthCheck CRDs"]
        controller["Kuberhealthy Controller"]
        pod["Check Pod\n(api-smoke-test)"]

        svc --> controller
        controller -->|watches| crds
        controller -->|schedules| pod
        pod -->|"POST /check"| controller
    end

    prometheus --> svc
    browser --> svc

Kuberhealthy provides the HealthCheck custom resource definition. Each HealthCheck tells Kuberhealthy to start a short-lived checker pod on a schedule.

The checker pod runs your validation logic, then reports back to Kuberhealthy. Results flow to the built-in status UI, JSON API, and Prometheus metrics endpoint.

Getting started

Installing Kuberhealthy is easy. Just apply the kustomize, ArgoCD, or Helm manifests and you're ready to start applying healthcheck resources.

  1. Install Kuberhealthy to your cluster:

    Helm (recommended)

    helm install kuberhealthy deploy/helm/kuberhealthy -n kuberhealthy --create-namespace
    

    Kustomize

    kubectl apply -k github.com/kuberhealthy/kuberhealthy/deploy/kustomize/base?ref=main
    

    ArgoCD

    kubectl apply -f deploy/argocd/kuberhealthy.yaml
    
  2. Port-forward the service:

    kubectl -n kuberhealthy port-forward svc/kuberhealthy 8080:80
    
  3. Open http://localhost:8080 to see the status UI, then apply a HealthCheck or build your own.

What a healthcheck CRD looks like

This is the core object Kuberhealthy manages. It tells the controller what checker container to run, how often to run it, and how long to wait before considering the run failed. You can use kubectl get healthcheck or kubectl get hc.

This example uses the built-in deployment check, which creates a test deployment, rolls it out, and tears it down on a schedule:

apiVersion: kuberhealthy.github.io/v2
kind: HealthCheck
metadata:
  name: deployment
  namespace: kuberhealthy
spec:
  runInterval: 10m
  timeout: 5m
  podSpec:
    spec:
      containers:
        - name: deployment
          image: docker.io/kuberhealthy/deployment-check:v0.1.1
          env:
            - name: CHECK_DEPLOYMENT_REPLICAS
              value: "4"
            - name: CHECK_DEPLOYMENT_ROLLING_UPDATE
              value: "true"
          resources:
            requests:
              cpu: 25m
              memory: 15Mi
            limits:
              cpu: "1"
      serviceAccountName: deployment-sa

See CHECK_CREATION.md for the environment variables injected into every check pod and how to build your own.

Example Healthcheck Use

Apply your healthcheck check:

> kubectl apply -f api-smoke-test.yaml
healthcheck.kuberhealthy.github.io/api-smoke-test.yaml created

> kubectl get healthcheck
NAME              NAMESPACE      LAST RUN    AGE    OK
api-smoke-test    kuberhealthy   2m ago      2d     true

Consume Check Status with Prometheus:

/metrics (Prometheus)

kuberhealthy_check{check="api-smoke-test",namespace="kuberhealthy",status="1"} 1
kuberhealthy_check{check="db-connectivity",namespace="kuberhealthy",status="0"} 1
kuberhealthy_check_duration_seconds{check="api-smoke-test",namespace="kuberhealthy"} 0.23
kuberhealthy_check_success_total{check="api-smoke-test",namespace="kuberhealthy"} 142

Fetch the status by API:

/json

{
  "ok": true,
  "checks": {
    "kuberhealthy/api-smoke-test": {
      "ok": true,
      "errors": [],
      "lastRun": "2024-01-15T14:32:01Z",
      "runDuration": "230ms"
    }
  }
}

Writing checks

Get started with CHECK_CREATION.md and the HealthCheck registry, then pick a check client for your language:

Language Client
Go github.com/kuberhealthy/kuberhealthy/v3/pkg/checkclient
Python kuberhealthy
TypeScript @kuberhealthy/kuberhealthy
JavaScript @kuberhealthy/kuberhealthy
Rust kuberhealthy
Ruby kuberhealthy
Java Maven / Gradle
Bash Shell script helper

Example: Go check that validates an internal API

package main

import (
    "fmt"
    "net/http"

    "github.com/kuberhealthy/kuberhealthy/v3/pkg/checkclient"
)

func main() {
    resp, err := http.Get("http://my-api.default.svc.cluster.local/health")
    if err != nil {
        checkclient.ReportFailure([]string{fmt.Sprintf("request failed: %s", err)})
        return
    }
    defer resp.Body.Close()

    if resp.StatusCode != http.StatusOK {
        checkclient.ReportFailure([]string{fmt.Sprintf("unexpected status %d from /health", resp.StatusCode)})
        return
    }

    checkclient.ReportSuccess()
}

The check client handles KH_REPORTING_URL, KH_RUN_UUID, and deadline enforcement automatically.

Documentation

See the full documentation index in docs/README.md.

Adopters

See docs/ADOPTERS.md for organizations running Kuberhealthy in production.

Contributing

  • Read the Contributing Guide before opening a PR.
  • Browse open issues — new contributors should look for the good first issue tag.
  • Check contributions are especially welcome — see the HealthCheck registry for gaps.
  • Have feedback from running Kuberhealthy in production? Open a discussion or join Slack.

Community

相关仓库
kubernetes/kubernetes

Production-Grade Container Scheduling and Management

GoGo ModulesApache License 2.0kubernetesgo
kubernetes.io
123.9k43.7k
bregman-arie/devops-exercises

Linux, Jenkins, AWS, SRE, Prometheus, Docker, Python, Ansible, Git, Kubernetes, Terraform, OpenStack, SQL, NoSQL, Azure, GCP, DNS, Elastic, Network, Virtualization. DevOps Interview Questions

PythonPyPIOtherdevopsaws
83.3k19.8k
netdata/netdata

The fastest path to AI-powered full stack observability, even for lean teams.

GoGo ModulesGNU General Public License v3.0monitoringdocker
netdata.cloud
79.8k6.5k
traefik/traefik

The Cloud Native Application Proxy

GoGo ModulesMIT Licensemicroservicedocker
traefik.io
64.1k6.1k
minio/minio

MinIO is a high-performance, S3 compatible object store, open sourced under GNU AGPLv3 license.

GoGo ModulesGNU Affero General Public License v3.0gostorage
61.4k7.7k
etcd-io/etcd

Distributed reliable key-value store for the most critical data of a distributed system

GoGo ModulesApache License 2.0etcdraft
etcd.io
52k10.4k
GitHubDaily/GitHubDaily

坚持分享 GitHub 上高质量、有趣实用的开源技术教程、开发者工具、编程网站、技术资讯。A list cool, interesting projects of GitHub.

githubopen-source
githubdaily.com
47.1k4.7k
LeCoupa/awesome-cheatsheets

👩‍💻👨‍💻 Awesome cheatsheets for popular programming languages, frameworks and development tools. They include everything you should know in one single file.

JavaScriptnpmMIT Licensecheatsheetsjavascript
lecoupa.github.io/awesome-cheatsheets/
46.2k6.7k
Kong/kong

🦍 The API and AI Gateway

LuaApache License 2.0api-gatewaymicroservices
konghq.com/install/
43.8k5.2k
istio/istio

Connect, secure, control, and observe services.

GoGo ModulesApache License 2.0microservicesservice-mesh
istio.io
38.3k8.3k
ToolJet/ToolJet

ToolJet is the open-source foundation of ToolJet AI - the enterprise app generation platform for building internal tools, dashboard, business applications, workflows and AI agents 🚀

JavaScriptnpmGNU Affero General Public License v3.0javascriptinternal-tools
tooljet.com
38.2k5.2k
portainer/portainer

Making Docker and Kubernetes management easy.

TypeScriptnpmzlib Licensedockerdocker-swarm
portainer.io
38k2.9k