Documentation ¶
Overview ¶
Package probez provides a simple http server that implements Kubernetes readiness probes (e.g. /livez and /readyz) that can be embedded in containers with long running processes or added to gin services to ensure that they can control how Kubernetes views their service state.
Index ¶
- Constants
- type Handler
- func (h *Handler) Healthy()
- func (h *Handler) Healthz(w http.ResponseWriter, _ *http.Request)
- func (h *Handler) IsHealthy() bool
- func (h *Handler) IsReady() bool
- func (h *Handler) Mux(mux *http.ServeMux)
- func (h *Handler) NotHealthy()
- func (h *Handler) NotReady()
- func (h *Handler) Ready()
- func (h *Handler) Readyz(w http.ResponseWriter, _ *http.Request)
- func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Use(router *gin.Engine)
- type Probe
- type Server
Constants ¶
const ( Healthz = "/healthz" Livez = "/livez" Readyz = "/readyz" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
The Probe Handler manages the health and readiness states of a container. When it is first created, it starts in a healthy, but not ready state. Users can mark the probe server as healthy, unhealthy, ready, or not ready, changing how it responds to HTTP Get requests at the /livez and /readyz endpoints respectively.
Users should either instantiate a new probez.Server and serve it on a bind address or they should configure a probez.Handler to use an http server or a gin router for serving requests. When the the service is ready, they should mark the probez.Handler as ready, and when it is shutting down, the server should be marked as not ready and unhealthy.
func (*Handler) Healthy ¶
func (h *Handler) Healthy()
Healthy sets the probe server to healthy so that it responds 204 No Content to liveness probes at the /livez endpoint.
func (*Handler) Healthz ¶
func (h *Handler) Healthz(w http.ResponseWriter, _ *http.Request)
Healthz implements the kubernetes liveness check and responds to /healthz and /livez
func (*Handler) NotHealthy ¶
func (h *Handler) NotHealthy()
NotHealthy sets the probe server to unhealthy so that it responds 503 Unavailable to liveness probes at the /livez endpoint.
func (*Handler) NotReady ¶
func (h *Handler) NotReady()
NotReady sets the probe server state to not ready so that it responds 503 Unavailable to readiness probes at the /readyz endpoint.
func (*Handler) Ready ¶
func (h *Handler) Ready()
Ready sets the probe server state to ready so that it responds 204 No Content to readiness probes at the /readyz endpoint. This operation is thread-safe.
func (*Handler) Readyz ¶
func (h *Handler) Readyz(w http.ResponseWriter, _ *http.Request)
Readyz implements the kubernetes readiness check and responds to /readyz requests.
type Probe ¶
type Server ¶
type Server struct { Handler // contains filtered or unexported fields }
Server is a quick way to get a probez.Handler service up and running, particularly for containers that do not necessarily serve HTTP requests.
func NewServer ¶
func NewServer() *Server
New returns a probez.Server that is healthy but not ready.
func (*Server) Serve ¶
Serve probe requests on the specified port, handling the /livez and /readyz endpoints according to the state of the server.