Git Product home page Git Product logo

ecs_erlang_cluster's Introduction

ECSErlangCluster

GitHub release Reviewed by Hound

This is a command line tool to create the Erlang cluster on AWS ECS. When start a ECS task, it needs sys.config and own identifier and IP address for Erlang cluster. Other node's identifiers and IP addresses are written in sys.config.

ecs_erlang_cluster command can get own identifier and IP address, and can generate sys.config which has sibling nodes identifier and IP address. So you only have to launch the application by passing the result of this command.

Installation

This is an escript command, so you can install using mix command.

$ mix escript.install github h3poteto/ecs_erlang_cluster
* Getting new package (https://github.com/h3poteto/ecs_erlang_cluster.git)
remote: Enumerating objects: 93, done.
remote: Counting objects: 100% (93/93), done.
...

It will be installed in ~/.mix/escripts, so please add this path in your $PATH.

Usage

At first, get your task identifier and IP address.

$ export ONESELF=`ecs_erlang_cluster oneself`

Second, generate sys.config file.

$ ecs_erlang_cluster generate \
  --cluster your_cluster_name \
  --service your_service_name \
  --region ap-northeast-1 \
  --minport 4370 \
  --maxport 4370

$ ls
sys.config

And you can run your elixir or erlang process.

$ iex --name $ONESELF --cookie hogehoge --erl "-config sys.config" -S mix

Note

Fargate support

Now this command supports only EC2 type, not Fargate. And it doesn't support awsvpc as network mode. It supports only bridge.

Port mapping

When you use this command, you should pay attention to port mapping of ECS task. ErlangVM use two type port to connect other VM.

  1. epmd port: 4369
  2. connection port: random

First, you can not change epmd port. So you have to define port mapping for epmd port.

Second, connection port is random, but you can specify in sys.config. So ecs_erlang_cluster can specify minport and maxport. You have to define port mapping same as min/max port; For example 4370.

In conclusion, you should create following container definitions:

[
  {
    "name": "container-name",
    "image": "elixir",
    "portMappings": [
      {
        "containerPort": 4369,
        "hostPort": 4369,
        "protocol": "tcp"
      },
      {
        "containerPort": 4369,
        "hostPort": 4369,
        "protocol": "udp"
      },
      {
        "containerPort": 4370,
        "hostPort": 4370,
        "protocol": "tcp"
      },
      {
        "containerPort": 4370,
        "hostPort": 4370,
        "protocol": "udp"
      }
    ],
    ...
  }
]

You don't use dynamic port mapping, because epmd can not manage dynamic port mapping.

IAM Policy

Please prepare IAM policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ecs:ListTasks",
        "ecs:DescribeTasks",
        "ecs:DescribeContainerInstances",
        "ec2:DescribeInstances"
      ],
      "Resource": "*"
    }
  ]
}

And attach this to your task IAM Role.

License

The package is available as open source under the terms of the MIT License.

ecs_erlang_cluster's People

Contributors

h3poteto avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.