# `Cluster.Strategy.Rancher`
[🔗](https://github.com/bitwalker/libcluster/blob/3.6.0/lib/strategy/rancher.ex#L1)

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.

```sh
#!/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]]]

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `start_link`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
