Kubernetes-native health checking for your deployments
Verify your pods are ready before traffic hits them
A production-ready Kubernetes tool that automatically finds your recently deployed pods and verifies they're healthy before considering your deployment successful. Perfect for preview environments, CI/CD pipelines, and zero-downtime deployments.
- π Preview Environments: Ensure your feature branch is actually working before showing it to stakeholders
- π CI/CD Integration: Block deployments until pods are genuinely ready to serve traffic
- β‘ Zero-Downtime: Verify new deployments without manual intervention
- π‘οΈ Production Safety: Catch deployment issues before they affect users
Head over to the deploy/
directory and apply the provided Kubernetes Job manifest:
# Example: Check if your deployment is ready
env:
- name: NAMESPACE
value: "my-app-namespace"
- name: LABEL_SELECTORS
value: "app=my-app,version=v2.1.0"
- name: ENDPOINT
value: "/api/health"
The job will automatically:
- π Find your most recent pod matching the labels
- π©Ί Perform health checks with smart retry logic
- β Exit successfully when your pod is ready
- π¨ Fail fast if something's wrong
The deploy/job.yml
provides a production-ready Kubernetes Job with:
- β Security hardened (non-root, read-only filesystem, dropped capabilities)
- β RBAC configured with minimal required permissions
- β Resource limits and best practices applied
- β Configurable via environment variables
Simply apply it and customize the environment variables for your use case.
Environment Variable | Description | Default | Example |
---|---|---|---|
NAMESPACE |
Target namespace | "" (all) |
production |
LABEL_SELECTORS |
Pod labels (comma-separated) | required | app=api,version=v1.2 |
ENDPOINT |
Health check path | /healthz |
/api/v1/health |
SCHEME |
Protocol | http |
https |
PORT |
Target port | auto-detect | 8080 |
TIMEOUT |
Request timeout (seconds) | 5 |
10 |
RETRIES |
Max retry attempts (0=infinite) | 0 |
5 |
STATUS_CODE |
Expected HTTP status | 200 |
204 |
graph LR
A[π Job Starts] --> B[π Find Latest Pod]
B --> C{π Pod has IP?}
C -->|No| D[β³ Wait + Retry]
D --> C
C -->|Yes| E[π©Ί Health Check]
E --> F{β
Healthy?}
F -->|No| G[β³ Smart Retry]
G --> E
F -->|Yes| H[π Success!]
Smart Features:
- π― Jitter logic prevents thundering herd effects
- π Exponential backoff for failed requests
- π Millisecond precision timing
- πͺ Graceful degradation for edge cases
π³ Container Images
# GitHub Container Registry (recommended)
docker pull ghcr.io/meysam81/liveness-check:latest
# Docker Hub
docker pull meysam81/liveness-check:latest
π¦ Go Install
go install github.com/meysam81/liveness-check@latest
π§ Build from Source
git clone https://github.com/meysam81/liveness-check.git
cd liveness-check
go build -o liveness-check
# Verify your feature branch before demo
env:
- name: LABEL_SELECTORS
value: "app=frontend,branch=feature-awesome-ui"
# Check new version before traffic switch
env:
- name: LABEL_SELECTORS
value: "app=api,version=v2.0.0,deployment=green"
# Ensure each pod is ready during rolling update
env:
- name: LABEL_SELECTORS
value: "app=backend,release=canary"
Made with β€οΈ for the Kubernetes community
β Star this repo β’ π Report issues β’ π¬ Get support