Cluster setup

In the previous section (Installation), preinstall_cluster.sh script created directory /opt/getint/cluster and put there all needed scripts/properties to manage cluster.

To use any of above scripts, it is mandatory to first edit cluster.env file which contains all needed variables for running cluster. So let's edit this file.

cd /opt/getint/cluster
ln -s cluster.env .env
vim cluster.env

To save and quit vim, type in ":wq". To start editing file, press "i"

This is how the cluster.env file default content looks like.

cluster.env
PORT=<CLUSTER_PORT>
LOGGING_DIR=/opt/getint/cluster/logs
SPRING_DATASOURCE_USER=<POSTGRES_USER>
SPRING_DATASOURCE_PASSWORD=<POSTGRES_PASS>
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:<POSTGRES_PORT>/<POSTGRES DB>
TENANTS_SECURITY_TOKEN=<PROVIDE LONGER HASH>
TENANTS_DOMAIN=<MAIN DOMAIN OF CLUSTER>

Variable

Description

<CLUSTER_PORT>

HTTP Port on which you want to have a cluster running on your machine

<POSTGRES_USER>

Postgres user created with usage of psql command in Installation step

<POSTGRES_PASS>

Password assigned to created user on Installation step

<POSTGRES_PORT>

Port on which PostgreSQL databse is running. Default is 5432. Important: if PostgreSQL is placed on another machine (host), you may need to replace whole localhost with that host name

<PROVIDE LONGER HASH>

Hash being an token to authenticating API requests sent to cluster to manage tenants. Type whatever random string you want, just use numbers and letters

<MAIN DOMAIN OF CLUSTER>

Because cluster is using subdomains to distinguish tenants, type here a main domain under which those tenants will be placed. E.g. if you would like to have 2 tenants available under urls like t1.getint.company.com and t2.getint.company.com just type here getint.company.com

And this is how the example of edited cluster.env file can look like

PORT=8300
LOGGING_DIR=/opt/getint/cluster/logs
SPRING_DATASOURCE_USER=cluster_user
SPRING_DATASOURCE_PASSWORD=root
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/cluster_db
TENANTS_SECURITY_TOKEN=gy3e2dt87gidu132te87dfqadhjsa
TENANTS_DOMAIN=tmp.getint.io

NGINX configuration

To forward traffic we are suggesting to use already installed in previous step, NGINX. With that tool also SSL certificates can be set up to enable secured communication protocol.

Within /opt/getint/cluster except some bash scripts, there should be already some template NGINX server configurations:

  • cluster_nginx_https.conf - can be used to set a secured communication

  • cluster_nginx_http.conf - can be used to set normal communication with SSL protocol

Once you selected which one to use, you have to:

1) Include it in a NGINX configuration by editing nginx.conf file

sudo vim /etc/nginx/nginx.conf

Put an include directive within http directive in above file. Comment out files included in default. Save file.

#include /etc/nginx/conf.d/*.conf;
#include /etc/nginx/sites-enabled/*;
include /opt/getint/cluster/cluster_nginx_http.conf;

2) Edit chosen NGINX configuration file (either http or https) and replace placeholders with real values, which you provided already when editing cluster.env. For example edited file can look like this

server {
listen 80;
server_name *.temp.getint.io;
location / {
proxy_pass http://localhost:8300;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 90;
proxy_redirect http://127.0.0.1:8300 $host;
}
}

3) Restart NGINX. If anything will be wrong you will see some errors printed out once your execute below command

sudo nginx -s reload