Libcluster on render.com: node() returns nonode@nohost

Hi all,

After adding libcluster to my phoenix app with two instances, node() returns nonode@nohost and List.node() returns [].

[1] states that Render creates nodes with names like elixir-cluster-demo@10.200.30.4, but I don’t know if I have to do anything to set up that.

The documentation [1] is for phoenix 1.4 and I use 1.6 so something could be missing.

I added libcluster to deps in mix.exs — I tried both 3.1 and the last version 3.3.1:

defp deps do
   [ ...,
     {:libcluster, "~> 3.1"}
   ]

Then I added the strategy that [1] recommends — Kubernetes.DNS — to runtime.exs:

dns_name = System.get_env("RENDER_DISCOVERY_SERVICE")
app_name = System.get_env("RENDER_SERVICE_NAME")

config :libcluster,
  topologies: [
    render: [
      strategy: Cluster.Strategy.Kubernetes.DNS,
      config: [
        service: dns_name,
        application_name: app_name
      ]
    ]
  ]

And in application.ex:

def start(_type, _args) do
    topologies = Application.get_env(:libcluster, :topologies) || []

    children = [
      {Cluster.Supervisor, [topologies, [name: MyApp.ClusterSupervisor]]},
      ...
    ]

    opts = [strategy: :one_for_one, name: MyApp.Supervisor]
    Supervisor.start_link(children, opts)
  end

Am I missing something? Why node() does return nonode@nohost? Thank you!

[1] Deploy a Distributed Elixir Cluster | Render

It is working.

The problem was that I was checking node() from a console instead of a server :sweat_smile: