KamilLelonek / healthchex

A set of Plugs to be used for Kubernetes healthchecks.

Home Page:https://medium.com/@KamilLelonek/liveness-and-readiness-probes-for-kubernetes-in-phoenix-application-890e24d0737e

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

healthchex

Build Status

Kubernetes Liveness and Readiness Probes as Elixir Plugs.

Installation

The package can be installed by adding healthchex to your list of dependencies in mix.exs:

def deps do
  [
    {:healthchex, "~> 0.2"}
  ]
end

Usage

To keep the documentation up to date, I decided to not duplicate it here, but include all usage examples as test cases.

Have a look at test/probes directory to see how you can use these Plugs.

Basic

defmodule MyApp.Router do
  use Phoenix.Router

  forward("/health/live", Healthchex.Probes.Liveness)
  forward("/health/ready", Healthchex.Probes.Readiness)

  pipeline :api do
    plug :accepts, ["json"]
  end

  scope "/api", MyApp do
    pipe_through :api
  end
end

With custom readiness probe

defmodule MyApp.Router do
  use Phoenix.Router

  forward "/health/live", Healthchex.Probes.Liveness
  forward "/health/ready", Healthchex.Probes.Readiness, probe: &Domain.db_ready?/0

  pipeline :api do
    plug :accepts, ["json"]
  end

  scope "/api", MyApp do
    pipe_through :api
  end
end

About

A set of Plugs to be used for Kubernetes healthchecks.

https://medium.com/@KamilLelonek/liveness-and-readiness-probes-for-kubernetes-in-phoenix-application-890e24d0737e


Languages

Language:Elixir 100.0%