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.
1
cd /opt/getint/cluster
2
ln -s cluster.env .env
3
vim cluster.env
Copied!
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
1
PORT=<CLUSTER_PORT>
2
​
3
LOGGING_DIR=/opt/getint/cluster/logs
4
​
5
SPRING_DATASOURCE_USER=<POSTGRES_USER>
6
SPRING_DATASOURCE_PASSWORD=<POSTGRES_PASS>
7
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:<POSTGRES_PORT>/<POSTGRES DB>
8
​
9
TENANTS_SECURITY_TOKEN=<PROVIDE LONGER HASH>
10
TENANTS_DOMAIN=<MAIN DOMAIN OF CLUSTER>
Copied!
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
1
PORT=8300
2
3
LOGGING_DIR=/opt/getint/cluster/logs
4
​
5
SPRING_DATASOURCE_USER=cluster_user
6
SPRING_DATASOURCE_PASSWORD=root
7
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/cluster_db
8
​
9
TENANTS_SECURITY_TOKEN=gy3e2dt87gidu132te87dfqadhjsa
10
TENANTS_DOMAIN=tmp.getint.io
Copied!

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
1
sudo vim /etc/nginx/nginx.conf
Copied!
Put an include directive within http directive in above file. Comment out files included in default. Save file.
1
#include /etc/nginx/conf.d/*.conf;
2
#include /etc/nginx/sites-enabled/*;
3
include /opt/getint/cluster/cluster_nginx_http.conf;
Copied!
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
1
server {
2
listen 80;
3
server_name *.temp.getint.io;
4
5
location / {
6
proxy_pass http://localhost:8300;
7
proxy_set_header Host $host;
8
proxy_set_header X-Real-IP $remote_addr;
9
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
10
proxy_set_header X-Forwarded-Proto $scheme;
11
proxy_read_timeout 90;
12
proxy_redirect http://127.0.0.1:8300 $host;
13
}
14
}
Copied!
3) Restart NGINX. If anything will be wrong you will see some errors printed out once your execute below command
1
sudo nginx -s reload
Copied!
​
Copy link