Skip to content

Google Compute Engine (GCE) clustering strategy for libcluster. It currently supports identifying nodes based on GCE labels.

License

Notifications You must be signed in to change notification settings

fremantle-industries/libcluster_gce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LibclusterGCE

Build Status hex.pm version

This is a Google Compute Engine (GCE) clustering strategy for libcluster. It currently supports identifying nodes based on compute engine labels.

Installation

Add :libcluster_gce to your project's mix dependencies.

def deps do
  [
    {:libcluster_gce, "~> 0.0.1"}
  ]
end

Requirements

libcluster_gce requires Elixir 1.11+ & Erlang/OTP 22+

Deployment Assumptions

Clustering will only apply to nodes that are accessible via the GCP internal DNS. If this doesn't fit your deployment strategy, please open a Github issue describing your deployment configuration.

Configuration

To cluster an application running in Google Compute Engine, define a topology for libcluster.

# config.exs
config :libcluster,
  topologies: [
    my_app: [
      strategy: ClusterGCE.Strategy.Labels,
      config: [
        project: "my-project",
        labels: %{
          "env" => "prod"
        }
      ]
    ]
  ]

Make sure a cluster supervisor is part of your application.

defmodule MyApp.App do
  use Application

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

    children = [
      {Cluster.Supervisor, [topologies, [name: MyApp.ClusterSupervisor]]},
      # ...
    ]
    Supervisor.start_link(children, strategy: :one_for_one, name: MyApp.Supervisor)
  end
end

Update your release's vm.args file to include the following lines.

## Name of the node
-name <%= release_name%>@${GOOGLE_COMPUTE_ENGINE_INSTANCE}.${GOOGLE_COMPUTE_ENGINE_ZONE}.c.${GOOGLE_CLOUD_PROJECT}.internal

## Limit distributed erlang ports to a single port
-kernel inet_dist_listen_min 9999
-kernel inet_dist_listen_max 9999

Run your application with the environment variable REPLACE_OS_VARS=true and forward the following tcp ports:

  • 4369 # epmd
  • 9999 # erlang distribution

Thanks

Shout out to @alexgaribay for the hard work in libcluster_gae.

Authors

License

libcluster_gce is released under the MIT license

About

Google Compute Engine (GCE) clustering strategy for libcluster. It currently supports identifying nodes based on GCE labels.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages