View Source Cluster.Strategy.Rancher (libcluster v3.4.1)

This clustering strategy is specific to the Rancher container platform. It works by querying the platform's metadata API for containers belonging to the same service as the node and attempts to connect them. (see: http://rancher.com/docs/rancher/latest/en/rancher-services/metadata-service/)

It assumes that all nodes share a base name and are using longnames of the form <basename@<ip> where the <ip> is unique for each node.

A way to assign a name to a node on boot in an app running as a Distillery release is:

Create a wrapper script which will interpolate the current ip of the container.

#!/bin/sh

export CONTAINER_IP="$(hostname -I | cut -f1 -d' ')"
export REPLACE_OS_VARS=true

/app/bin/app "$@"
# vm.args
-name app@${CONTAINER_IP}

An example configuration is below:

config :libcluster,
  topologies: [
    rancher_example: [
      strategy: Elixir.Cluster.Strategy.Rancher,
      config: [
        node_basename: "myapp",
        polling_interval: 10_000]]]

Summary

Functions

Returns a specification to start this module under a supervisor.

Callback implementation for Cluster.Strategy.start_link/1.

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Callback implementation for Cluster.Strategy.start_link/1.