Control Node

github.comhex.pmhexdocs.pm

🚀 Continuous Delivery and Orchestration as code for Elixir

Installation

def deps do
  [
    {:control_node, "~> 0.5.0"}
  ]
end

Introduction

control_node is an Elixir library which allows developers to build deployment and orchestration workflows as code.

With control_node library you can build your custom orchestration service tailored to your needs i.e. control_node offers APIs to store and manage release tars and deploy releases to remote hosts via SSH and monitor and manage deployed service nodes.

Pre-requisites

In order to use control_node you must ensure the following,

Features

Quick example

This library ships with an example service_app under example/ folder. You can try out this library by trying to deploy the release using the following steps,

Clone the repo

$ git clone https://github.com/beamX/control-node
$ cd control-code/

Start an SSH server locally where the release will be deployed,

$ docker-compose up -d

Start iex with distribution turned on

$ iex -S mix
Erlang/OTP 23 [erts-11.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.10.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :net_kernel.start([:control_node_test, :shortnames])
iex(control_node_test@hostname)2> 

Execute the Elixir code snippets in the console,

defmodule ServiceApp do
  use ControlNode.Release,
    spec: %ControlNode.Release.Spec{name: :service_app, base_path: "/app/service_app"}
end
host_spec = %ControlNode.Host.SSH{
  host: "localhost",
  port: 2222,
  user: "linuxserver.io",
  private_key_dir: Path.join([File.cwd!(), "test/fixture", "host-vm/.ssh"])
}
namespace_spec = %ControlNode.Namespace.Spec{
  tag: :testing,
  hosts: [host_spec],
  registry_spec: %ControlNode.Registry.Local{path: Path.join(File.cwd!(), "example")},
  deployment_type: :incremental_replace,
  release_cookie: :"YFWZXAOJGTABHNGIT6KVAC2X6TEHA6WCIRDKSLFD6JZWRC4YHMMA===="
}
{:ok, namespace_manager} = ControlNode.Namespace.start_link(namespace_spec, ServiceApp)
ControlNode.Namespace.deploy(namespace_manager, "0.1.0")
Node.list()

Connect and observe with observer

Once Node.list() shows that the control node is connected to the release nodes then observer can be used to observe and inspect the remote nodes,

l(:observer)
:observer.start()

Can control node be used to deploy non Elixir/Erlang project?

Yes.

TODO example

Under the hood

How it works

SSH server config to enable tunneling

In order to ensure that Control Node can connect to release node the SSH servers running the release should allow tunneling,

...
AllowTcpForwarding yes
...

Limitations