Skip to content

You are viewing documentation for Immuta version 2023.1.

For the latest version, view our documentation for Immuta SaaS or the latest self-hosted version.

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:

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