mirror of
https://github.com/stefanprodan/podinfo.git
synced 2026-03-03 18:40:21 +00:00
b839eba381c726a1207d5f96bf00bbac72aeaed2
k8s-podinfo
Podinfo is a tiny web application made with Go that showcases best practices of running microservices in Kubernetes.
Specifications:
- Multi-arch build and release automation (TravisCI)
- Multi-platform Docker image (amd64/arm/arm64/ppc64le/s390x)
- Health checks (readiness and liveness)
- Graceful shutdown on interrupt signals
- Prometheus instrumentation
- Dependency management with golang/dep
- Multi-level logging with golang/glog
- Error handling with pkg/errors
Web API:
GET /prints runtime information, environment variables, labels and annotationsGET /metricshttp requests duration and Go runtime metricsGET /healthzused by Kubernetes liveness probeGET /readyzused by Kubernetes readiness probePOST /readyz/enablesignals the Kubernetes LB that this instance is ready to receive trafficPOST /readyz/disablesignals the Kubernetes LB to stop sending requests to this instanceGET /paniccrashes the process with exit code 255
Instrumentation
Prometheus query examples of key metrics to measure and alert upon:
Request Rate - the number of requests per second by instance
sum(irate(http_requests_count{job=~".*podinfo"}[1m])) by (instance)
Request Errors - the number of failed requests per second by URL path
sum(irate(http_requests_count{job=~".*podinfo", status=~"5.."}[1m])) by (path)
Request Duration - average duration of each request over 10 minutes
sum(rate(http_requests_sum{job=~".*podinfo"}[10m])) /
sum(rate(http_requests_count{job=~".*podinfo"}[10m]))
Request Latency - 99th percentile request latency over 10 minutes
histogram_quantile(0.99, sum(rate(http_requests_bucket{job=~".*podinfo"}[10m])) by (le))
Goroutines Rate - the number of running goroutines over 10 minutes
sum(irate(go_goroutines{job=~".*podinfo"}[10m]))
Memory Usage - the average number of bytes in use by instance
avg(go_memstats_alloc_bytes{job=~".*podinfo"}) by (instance)
GC Duration - average duration of GC invocations over 10 minutes
sum(rate(go_gc_duration_seconds_sum{job=~".*podinfo"}[10m])) /
sum(rate(go_gc_duration_seconds_count{job=~".*podinfo"}[10m]))
Description
Languages
Go
76.8%
CUE
11.6%
HTML
3.7%
Makefile
3.4%
Shell
2.4%
Other
2.1%