vlcluster
v9.7.1
Published
VLCluster
Downloads
21
Readme
vlcluster
Simple docker and nginx-based cluster designed for multi-env web applications.
vlcluster is currently beeing restructured
Getting Started
vlcluster consists of four different node types
registry
Manages the cluster; stores and delivers applicationsworker
s Runinstance
s of applicationsgateway
s Create nginx-proxys toinstance
s running inworker
sclient
Developers; can manage the cluster and push new applications
You can put multiple different node types on the same computer
Setting up the cluster
You can use windows, macOS or linux to manage your cluster and uplaod new application, but the registry
, workers
and gateways
require linux with systemd
(ubuntu, centos, fedora, ...)!
Creating the registry
Run the following commands to create our first registry. We'll call it mainnet. You can only have one registry per cluster - but you can have multiple clusters and switch between them! Make sure that your registry has a static ip address or a DNS entry, we'll need it later on to reference the node!
This will create the registry in ~/.vlcluster
. The command will return a key. This key will be used later on to create the workers and clients
We need to make sure that vlcluster runs, even after a reboot. So, let's install it as a systemd
service!
sudo vlcluster daemon install -u root
Setting up our first worker
Now you can either switch to a new machine or install the worker and the registry on the same machine. Run the following commands to create a worker and assign it a endpoint
address.
We have to restart the daemon if your worker is on the same node as the registry.
sudo service vlcluster restart
If you're using a different node, install the vlcluster daemon with systemd
sudo vlcluster daemon install -u root
Creating a gateway
We want our requests to be able to get to our instance
s, so let's setup the gateway. You can do this on the same node as your worker
or registry
!
Restart the vlcluster daemon or install the daemon with systemd
, like we did with the worker!
Connecting to the cluster
Let's get our first app published on our new mainnet cluster!
First, let's create a client
. Open a new terminal on your computer and type
npm install -g vlcluster
vlcluster init
Now enter your email, the hostname of our registry (registry.example.com
in the example) and paste the key (8cfh8jVXPd4...
in our example).
You need to have docker installed on your system → Installation page
You don't need to run vlcluster as a daemon on your client.
Setting up applications
Clone vlcluster example and open a terminal in the project directory
Every vlcluster application requires a simple
Dockerfile
and apackage.json
withname
andversion
We'll deploy the vlcluster-example
application to our registry, with the env
productive.
We want to reach the application, right? Let's route your domain name (example-application.example.com:80
in this example) to the vlcluster-example
application - but only to instances running as productive.
example-application.example.com
will automatically be routed to the latest version of vlcluster-example
running as productive
. A simple deploy is all you need now! vlcluster will install the new version, await application start up, update the proxies and then stop the old instances - zero downtime deploys!
Imagine you'd wanna run a test environnement, and have it available on test.example-application.example.com
. All you'll have to do is just type in those commands:
Variables
Nobody wants hardcoded database connection strings! Thats why vlcluster allows you to create variables which will be set as ENV-variables in your applications
Just run:
The variables will be set after a deploy
or a vlcluster instance restart
Command Reference
Setup
vlcluster init [client] [-e | --email <email>] [-h | --hostname <registry hostname>] [-k | --key <registry key>]
vlcluster init registry [-n | --name <registry name>]
vlcluster init worker [-h | --hostname <registry hostname>] [-k | --key <registry key>] [-n | --name <worker name>]
vlcluster init endpoint [-c | --cluster <registry hostname>] [-h | --hostname <endpoint hostname>]
vlcluster init gateway [--cluster-hostname <cluster hostname>] [--cluster-key <cluster key>] [-n | --name <gateway name>] [--endpoint-hostname <endpoint hostname>]
vlcluster daemon install [-u | --user <user>]
Building and Publishing
vlcluster build [[ -p | --project-path ] <project path> = "."]
vlcluster push [-c | --cluster <registry hostname>] [[ -a | --application ] <application>] [[ -v | --version ] <version>]
vlcluster upgrade [-c | --cluster <registry hostname>] [[ -a | --application ] <application>] [[ -v | --version ] <version>] [[ -e | --env ] <environnement>] [-i | --instances <instance count>]
vlcluster deploy [-c | --cluster <registry hostname>] [[ -e | --env ] <environnement>] [[ -p | --project-path ] <project path> = "."] [-i | --instances <instance count>]
Variables
vlcluster var set [-c | --cluster <registry hostname>] [[ -n | --name ] <name>] [[ -v | --value ] <value>] [-a | --application [ <application> ]] [-e | --env [ <environnement> ]]
vlcluster var list [-c | --cluster <registry hostname>] [-a | --application [ <application> ]] [-e | --env [ <environnement> ]]
Instance Management
vlcluster instance list [-c | --cluster <registry hostname>] [-a | --application [ <application> ]] [-e | --env [ <environnement> ]]
vlcluster instance restart [-c | --cluster <registry hostname>] [-a | --application [ <application> ]] [-e | --env [ <environnement> ]]
Routing
vlcluster route domain [-c | --cluster <registry hostname>] [-h | --host <host>] [-p | --port <port>] [-a | --application <application>] [-h | --host <host>] [-e | --env <env>]
vlcluster route websocket [-c | --cluster <registry hostname>] [-h | --host <host>] [-p | --port <port>] [-l | --location <location>]
SSL
SSL certificates are created by certbot which needs to be installed on the gateways!
vlcluster ssl enable [-c | --cluster <registry hostname>] [-h | --host <host>] [-p | --port <port>]
Utitlity
vlcluster system # shows cluster system info
vlcluster daemon # runs vlcluster daemon