One of the steps for preparing BRIX infrastructure is to configure proxying of database queries. For this purpose, you can use the DB‑Gateway tool.
It provides access to the Redis, RabbitMQ, PostgreSQL, and MinIO databases via an entry point in the Kubernetes cluster. This simplifies the process of connecting to and working with databases, and optimizes the number of infrastructure components required to configure proxying.
DB‑Gateway installation consists of the following steps:
- Download the helm-chart and the configuration file.
- Fill out the configuration file.
- Install the DB-Gateway chart using Helm in the Kubernetes cluster.
- Connect to databases.
Step 1: Download the helm-chart and the configuration file
To install via the internet, obtain the values-dbgateway.yaml configuration file by running the command:
helm repo add brix365 https://charts.brix365.com
helm repo update
helm show values brix365/dbgateway > values-dbgateway.yaml
Obtaining the configuration file for installation in an isolated environment without internet access
- On a computer with internet access, download the archive of the DB-Gateway latest chart from the BRIX repository by running the command:
helm repo add brix365 https://charts.brix365.com
helm repo update
helm pull brix365/dbgateway
- Copy the
dbgateway-X.Y.Z.tgz chart archive to the server where the installation will be performed.
- Unzip the
dbgateway-X.Y.Z.tgz chart and copy the default values.yaml configuration file to values-mimir.yaml:
tar -xf dbgateway-X.Y.Z.tgz
cp dbgateway/values.yaml values-dbgateway.yaml
|
Step 2: Fill out the configuration file
Fill out the values-dbgateway.yaml configuration file for DB‑gateway installation:
- In the
ingress.hostname parameter, set the domain (FQDN) or the IP address of the BRIX application.
- In the
ingress.path parameter, set the bucket name (in the database storage) where the BRIX files are stored.
The bucket name in the database must correspond to the DBbrix365 format.
Начало примера
Example:
- DBbrix365.
- DBbrix365-dev.
- DBbrix365-prod.
конец примера
- The following changes should be made to the configuration file if the BRIX application web-interface is accessible via HTTPS:
- In the
ingress.hostname parameter, set the domain (FQDN).
- In the
ingress.ingressClassName parameter, set the name of the ingress controller class.
- Enable TLS support by setting the
ingress.tls parameter to true.
- Uncomment the parameters of the
ingress.extraTls section.
- For the
ingress.extraTls.hosts parameter, set the domain (FQDN) where the BRIX application is available.
- For the
ingress.extraTls.secretName parameter, set the secret name of the tls type for the domain specified in ingress.extraTls.hosts.
- If high availability is provided, set the required number of replicas in the
replicaCount parameter.
- In the configuration parameter, the HAProxy configuration is specified with which this tool will run in the Kubernetes cluster. In the
backend DB_main section of the HAProxy configuration, specify the list of database servers to which user traffic will be redirected.
How to configure HAProxy to proxy connection to a database repository
The example considers the Redis, RabbittMQ, PostgreSQL, and MinIO databases located outside the Kubernetes cluster and deployed according to the instructions in the High availability infrastructure section. Let's configure proxying of the user traffic for servers with these databases.
## HAProxy settings for proxying connection to database storage
haproxy:
global:
security:
allowInsecureImages: true
## enabling Gateway API support
httpRoute:
enabled: false
parentRefs:
- name: main-gateway
namespace: istio-system
ingress:
enabled: true
## enabling HAProxy Ingress support for working with OpenShift
openshift: false
## system's domain (FQDN)through which it is accessible
hostname: brix365-server.your-domain
## name of the bucket (in the S3 storage)for the BRIX application
path: /s3brix365
ingressClassName: "nginx"
## internal health-check/probe URL generated by MinIO to check availability
extraPaths:
- path: /probe-bsign(.*)
pathType: ImplementationSpecific
backend:
service:
name: dbgateway-haproxy
port:
name: http
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: '0'
# kubernetes.io/ingress.class: nginx
## enabling https
tls: false
# extraTls:
# - hosts:
# - brix365-server.your-domain
# secretName: brix365-server.your-domain-tls
## number of replicas to ensure high availability
replicaCount: 2
containerPorts:
- name: http
containerPort: 8080
- name: redis
containerPort: 6379
- name: sentinel
containerPort: 26379
- name: rabbitmq
containerPort: 5672
- name: rabbitmq-stats
containerPort: 15672
- name: postgres
containerPort: 5000
## HAProxy configuration
configuration: |
global
log stdout format raw local0
maxconn 1024
defaults
log global
timeout client 60s
timeout connect 60s
timeout server 60s
### S3 MinIO ###
frontend fe_s3_main
bind :8080
default_backend be_s3_main
backend be_s3_main
balance leastconn
server s3_1 192.168.1.241:9000 check inter 2s
server s3_2 192.168.1.242:9000 check inter 2s
server s3_3 192.168.1.243:9000 check inter 2s
server s3_4 192.168.1.244:9000 check inter 2s
### S3 MinIO ###
### Redis ###
listen redis_master
option tcplog
option clitcpka
bind :6379
balance first
mode tcp
timeout queue 2s
timeout connect 2s
timeout check 1s
option srvtcpka
timeout server 24h
server redis-server1 192.168.1.237:6379 check inter 5s
server redis-server2 192.168.1.238:6379 check inter 5s
server redis-server3 192.168.1.239:6379 check inter 5s
### Redis ###
### RabbitMQ ###
listen rabbitmq
bind :5672
mode tcp
balance roundrobin
server rabbitmq-server1 192.168.1.234:5672 check inter 2s rise 2 fall 3
server rabbitmq-server2 192.168.1.235:5672 check inter 2s rise 2 fall 3
server rabbitmq-server3 192.168.1.236:5672 check inter 2s rise 2 fall 3
listen rabbitmq_management
bind :15672
balance source
server rabbitmq-server1 192.168.1.234:15672 check inter 2s
server rabbitmq-server2 192.168.1.235:15672 check inter 2s
server rabbitmq-server3 192.168.1.236:15672 check inter 2s
### RabbitMQ ###
### PostgreSQL ###
listen postgres_master
bind :5000
option tcplog
option httpchk OPTIONS /master
http-check expect status 200
default-server inter 3s fastinter 1s fall 3 rise 4 on-marked-down shutdown-sessions
server postgres-server1 192.168.1.251:5432 check port 8008
server postgres-server2 192.168.1.252:5432 check port 8008
server postgres-server3 192.168.1.253:5432 check port 8008
listen postgres_replicas
bind :5001
option tcplog
option httpchk OPTIONS /replica
balance roundrobin
http-check expect status 200
default-server inter 3s fastinter 1s fall 3 rise 2 on-marked-down shutdown-sessions
server postgres-server1 192.168.1.251:5432 check port 8008
server postgres-server2 192.168.1.252:5432 check port 8008
server postgres-server3 192.168.1.253:5432 check port 8008
### PostgreSQL ###
## safety context policy
podSecurityContext:
enabled: true
fsGroup: 1001
containerSecurityContext:
enabled: true
runAsUser: 1001
runAsNonRoot: true
## specifying resources
resources:
requests:
memory: "64Mi"
cpu: "50m"
limits:
memory: "512Mi"
cpu: "500m"
...
|
- If you install DB-Gateway chart in an isolated environment without internet access, fill out the connection parameters for the private registry.
How to fill out the connection parameters for the private registry
- Set the address in the
haproxy.image.registry parameter.
- Set the path in the
haproxy.image.repository parameter.
- Set the secret name with the access permissions for the private registry in the
haproxy.image.pullSecrets parameter (the secret must be manually created and encrypted in Base64).
# HAProxy settings for proxying connection to the database storage
haproxy:
...
# Parameters for connecting to the private registry
image:
# address and path for the private registry
registry: registry.example.com
repository: /bitnami/haproxy
tag: 3.0.5-debian-12-r0
# the secret with access permissions to the private registry must be manually created and encrypted in Base64
pullSecrets:
- myRegistryKeySecretName
|
Step 3: Install the DB-Gateway chart using Helm in the Kubernetes cluster
Install the DB-Gateway chart in the namespace dbgateway.
To install via the internet, run the command:
helm upgrade --install dbgateway brix365/dbgateway -f values-dbgateway.yaml -n dbgateway --create-namespace
To install without internet access, run the command:
helm upgrade --install dbgateway ./dbgateway -f values-dbgateway.yaml -n dbgateway --create-namespace
Step 4: Connect to databases
In the values-elma365.yaml configuration file, fill out the parameters for BRIX application to connect to databases via the configured DB‑Gateway:
- Parameters for connecting to MinIO:
address — specify elma365-server.your_domain.
bucket, region, access key ID, secret access key, upload method и enable SSL — specify values according to the parameters of the DB storage for which proxying is configured.
- Parameters for connecting to Redis:
brix365.db.redisUrl — 'redis://:SecretPassword@redis.dbgateway.svc.cluster.local:6379/0';
- Parameters for connecting to RabbitMQ:
brix365.db.amqpUrl — 'amqp://brix365user:SecretPassword@rabbitmq.dbgateway.svc.cluster.local:5672/0'
brix365.db.amqpManagementUrl — 'http://rabbitmq-stats.dbgateway.svc.cluster.local:15672';
- Parameters for connecting to PostgreSQL:
brix365.db.psqlUrl — 'postgres://brix365user:SecretPassword@postgresql.dbgateway.svc.cluster.local:5000/brix365?sslmode=disable'
brix365.db.roPsqlUrl — 'postgresql://brix365user:SecretPassword@postgresqlro.dbgateway.svc.cluster.local:5001/brix365?sslmode=disable';
Read how to fill out these parameters in the Modify BRIX parameters article.