Skip to content

Configuring the Immuta PostgreSQL Instance

Audience: Application Admins

Content Summary: Immuta uses a tool called Patroni to manage streaming replication of the PostgreSQL database. The implication is that in order to change PostgreSQL setting you need to interact with the Patroni API.

This page outlines how to change the PostgreSQL settings, connect to the database container, modify the configuration, and apply changes and restart the cluster.

Changing PostgreSQL Settings

The easiest way to interact with the Patroni API is using a tool called patronictl that is installed in the Immuta database docker containers. Updating the PostgreSQL settings involves 3 processes:

  1. Connect to the database container.
  2. Use patronictl to modify the configuration.
  3. Use patronictl to restart the database and propagate the changes.

Connect to the Database Container

  1. Use kubectl to determine the name of the pod running the PostgreSQL master:

    For the metadata database:

    kubectl get pods -l app=immuta,component=postgres,immuta-database-role=metadata,immuta-ha-postgres-role=master
    

    For the Immuta Query Engine database:

    kubectl get pods -l app=immuta,component=postgres,immuta-database-role=immuta,immuta-ha-postgres-role=master
    
  2. 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

  1. Once inside the database container, you can run patronictl to modify the configuration.

  2. A few environment variables must be exported for the patronictl edit-config command to run successfully:

    export EDITOR=vi
    
  3. The following command will then open up the PostgreSQL configuration in vi for editing.

    patronictl edit-config -q
    
  4. Make any changes, and then close the vi session by saving the configuration (Type <ESC>:wq).

  5. 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.

  1. Get the Patroni cluster name:

    patronictl list
    
  2. 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.

  3. 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>