Configure the Immuta PostgreSQL Instance
Audience: Application Admins
Content Summary: Immuta uses the tool Patroni to manage streaming replication of the PostgreSQL database. You need to interact with the Patroni API in order to change PostgreSQL setting.
This page outlines how to change the PostgreSQL settings, connect to the database container, modify the configuration, and apply changes and restart the cluster.
Change PostgreSQL Settings
The easiest way to interact with the Patroni API is using the tool
patronictl
that is installed in the Immuta database docker containers. Updating the PostgreSQL settings involves 3 processes:
- Connect to the database container.
- Use
patronictl
to modify the configuration. - Use
patronictl
to restart the database and propagate the changes.
Connect to the Database Container
-
Use
kubectl
to determine the name of the pod running the PostgreSQL master:For the metadata database:
kubectl get pods -l app.kubernetes.io/component=database,app.kubernetes.io/name=immuta,k8s.immuta.com/database-role=master
For the Immuta Query Engine database:
kubectl get pods -l app.kubernetes.io/component=query-engine,app.kubernetes.io/name=immuta,k8s.immuta.com/database-role=master
-
Make note of the pod name, which will be used when connecting:
kubectl exec -ti <pod name> bash
The following steps should be executed from within this context.
Modify the Configuration
-
Once inside the database container, you can run
patronictl
to modify the configuration. -
A few environment variables must be exported for the
patronictl edit-config
command to run successfully:export EDITOR=vi
-
The following command will then open up the PostgreSQL configuration in
vi
for editing.patronictl edit-config -q
Optional Flags
edit-config
can be used with other flags set to specific values:Parameter Description -q
,--quiet
Do not show changes. -s
,--set
With additional text, this parameter will set a specific configuration value. Can be specified multiple times. -p
,--pg
With additional text, this parameter will set the specific PostgreSQL parameter value. Can be specified multiple times. -
Make any changes, and then close the
vi
session by saving the configuration (Type<ESC>:wq
). -
You will be asked if you would like to apply the changes; type
y
and press enter.
Apply the Changes and Restart the Cluster
Now that changes have been made you can push these changes out using
patronictl restart
.
-
Get the Patroni cluster name:
patronictl list
-
The cluster name is the first column in the result. There should be only one unique value. Use this cluster name in the call to
patronictl restart
. -
If you have modified the value of
max_connections
, then you should use the following command to restart the master instance only; the changes will propagate to the replicas automatically:export REQUESTS_CA_BUNDLE=${CA_FILE} patronictl restart <cluster name> -r master
If you have not modified the value of
max_connections
you can simply run the following command:export REQUESTS_CA_BUNDLE=${CA_FILE} patronictl restart <cluster name>