Connecting the deployed Elixir nodes
Our objective in this section is to connect every ElixirDrip node running in Kubernetes. With the current setup, each Elixir node is running on its own pod, without even trying to connect to other pods.
When we introduced the Kubernetes deployment template, we briefly talked about the /health
endpoint used by the readiness and liveness probe. Let's use this endpoint to get information about the node that replies to our HTTP GET requests. Here you can find the Phoenix controller that will handle the requests to /health
:
$ cat apps/elixir_drip_web/lib/elixir_drip_web/controllers/ health_controller.ex defmodule ElixirDripWeb.HealthController do @moduledoc false use ElixirDripWeb, :controller def health(conn, _params) do {_, timestamp} = Timex.format(DateTime.utc_now, "%FT%T%:z", :strftime) {:ok, hostname} = :inet.gethostname json(conn, %{ ok: timestamp, hostname: to_string(hostname), node: Node.self(), connected_to...