Skip to content

wuunder/libcluster_ecs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClusterEcs

Use this library to set up clustering within AWS ECS.

This library, unlike others, does not rely on configuring your nodes with awsvpc networking mode. Instead it queries ECS's port mappings to accomplish the goal.

Getting started

Create a container port mapping (eg, container port 7777 to host port 0, this will assign a random port).

Configure the libcluster topology:

config :libcluster,
  topologies: [
    mycluster: [
      strategy: Cluster.EcsStrategy,
      config: [
        cluster_name: "mycluster",
        service_name: "myservice",
        app_prefix: "myapp_prefix",
        region: "eu-west-1",
        container_port: 7777
      ]
    ]
  ]

Add Cluster.EcsClusterInfo to your supervision tree before the cluster supervisor and provide it with your config:

children = [
  ...
  {Cluster.EcsClusterInfo, Application.get_env(:libcluster, :topologies)[:mycluster][:config]},
  {Cluster.Supervisor, [Application.get_env(:libcluster, :topologies), [name: MyApp.ClusterSupervisor]]}
  ...
  ]

Configure libcluster EPMD by setting DISTRIBUTION_PORT in rel/env.sh.eex. This needs to be an env var because this EPMD module is used during startup and application configuration is not available yet:

export DISTRIBUTION_PORT=7777

Add the following line to rel/vm.args.eex:

-epmd_module Elixir.Cluster.EPMD

Configure (if you haven't already) ex_aws. The IAM user that you configure needs the following permissions:

ecs:ListClusters"
ecs:ListServices
ecs:ListTasks
ecs:DescribeTasks
ecs:DescribeContainerInstances
ec2:DescribeInstances

Installation

If available in Hex, the package can be installed by adding libcluster_ecs to your list of dependencies in mix.exs:

def deps do
  [
    {:libcluster_ecs, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/libcluster_ecs.

About

ECS clustering that "just works"

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages