Skip to content

Multiple Virtual Network

How to make virtual network

You can install multiple hosts, if they reach the same redis instance and elastic (data plane), they behave like a cluster. If hosts are in different regions, they can reach the redis and elastic over wireguard or IPSec. There is no need directly communication between hosts.

Creating Gateways

For creating a virtual network, at least you need one gateway. You can list, start, stop, delete gateways

Gateway commands

    ferrumgate --list-gateways
    ferrumgate --start-gateway $gatewayId
    ferrumgate --stop-gateway $gatewayId
    ferrumgate --delete-gateway $gatewayId
    ferrumgate --recreate-gateway
    ferrumgate --create-gateway

Create gateway asks for a port number, host will start to listen on that port number.

Create Cluster

At least 3 hosts we need to perform a cluster.

Host A Host B Host C
public IP 192.168.88.10 192.168.88.11 192.168.88.13

Prepare env

First select Host A as master. And copy some keys from A to others

On Host A

    ferrumgate --show-config ENCRYPT_KEY
    ferrumgate --show-config REDIS_PASS
    ferrumgate --show-config ES_PASS

On Host B and on Host C

    ferrumgate --set-config ENCRYPT_KEY
    ferrumgate --set-config REDIS_PASS  
    ferrumgate --set-config REDIS_INTEL_PASS # same REDIS_PASS output
    ferrumgate --set-config ES_PASS
    ferrumgate --set-config ES_INTEL_PASS # same  ES_PASS output

on each machine /etc/ferrumgate/env file, REDIS_PASS, REDIS_INTEL_PASS must be same, REDIS_LOCAL_PASS can be different. ES_PASS, ES_INTEL_PASS must be same

Create Host cluster

  • Get cluster info
    ferrumgate --show-cluster
  • Set each machine name with a memorable one On each machine
    ferrumgate --set-cluster-config

type host and set new names like fs1,fs2,fs3 or california, paris, singrapore

  • On Host A
    export CLUSTER_PUBLIC_IP=192.168.88.10 # your machine public reachable ip
    export CLUSTER_PUBLIC_PORT=54321
    ferrumgate --show-cluster-config

then copy 2 commands, that looks like below

PEER="fs1/192.168.88.10:54321/169.254.254.51/37ab2e7241cda59be515d6ee6b5dec0a45a026b4c206271acc0bb3f6b2fb6426"

ferrumgate --add-cluster-peer $PEER

copy these 2 commands and

paste on Host B and on Host C

  • On Host B
    export CLUSTER_PUBLIC_IP=192.168.88.11 # this ip is Host B public ip
    export CLUSTER_PUBLIC_PORT=54321
    ferrumgate --show-cluster-config

then copy 2 commands, that looks like below

PEER="fs2/192.168.88.11:54321/169.254.254.54/3adfaadfa5d6ee6b5dec0a45a026b4c206271acc0bb3f6b2fb6426"

ferrumgate --add-cluster-peer $PEER

copy these 2 commands and

paste on Host A and on Host C

  • On Host C

Do the same with Host C ip

Testing Host Cluster

On each machine type,

    ferrumgate --show-cluster-config

Under current host section, there is records like below

host: fs1

ip: 169.254.254.51

port: 54321

pubKey: 37ab2e7241cda59be515d6ee6b5dec0a45a026b4c206271acc0bb3f6b2fb6426

ip is the cluster node ip, every host has a ip from 169.254.254.0/24 network. ping each ip on every node. and record this ips for next clustering steps. If ping is successfull, then you created a host cluster network. Next step is REDIS CLUSTER

Warning

please restart ferrumgate with

    ferrumgate --restart

Create redis cluster

We will connect all redis instances on Host A, Host B and Host C.

  • On Host A
    ferrumgate --show-config REDIS_PASS
    ferrumgate --set-redis-master

enter Host A cluster ip that starts with 169.254.254.*

  • On Host B
    ferrumgate --set-redis-master

enter Host A cluster ip that starts with 169.254.254.*

connect Host B redis and set replication to Host A

    docker run -ti redis:7-bullseye redis-cli -h $HOST_B_CLUSTER_IP 
    auth $REDIS_PASS
    replicaof $HOST_A_CLUSTER_IP 6379
    config rewrite
  • On Host C

Do the same things as Host B

    ferrumgate --set-redis-master

enter Host A cluster ip that starts with 169.254.254.*

connect Host C redis and set replication to Host A

    docker run -ti redis:7-bullseye redis-cli -h $HOST_C_CLUSTER_IP 
    auth $REDIS_PASS
    replicaof $HOST_A_CLUSTER_IP 6379
    config rewrite

Warning

please restart ferrumgate

Create ES Cluster

We are not creating an ES Cluster, instead of we are Active/Passive Elastic Search Instances.

We will set Host A Elastic Search as master and the others for backup. If Host A fails, Host B will continue

  • On Host A
    ferrumgate --show-es-peer

please copy 2 lines like below

PEER="fs1/169.254.254.51"

ferrumgate --add-es-peer $PEER

please type these commands on Host A,Host B, Host C

  • On Host B
    ferrumgate --show-es-peer

please copy 2 lines and please type these commands on Host A,Host B, Host C

  • On Host C
    ferrumgate --show-es-peer

please copy 2 lines and please type these commands on Host A,Host B, Host C

Warning

please restart ferrumgate

Or Just Changing ES and REDIS to an external resource

  • Redis Config
    ferrumgate --set-config redis
  • ElasticSearch Config
    ferrumgate --set-config es