Skip to content

Changing PostgreSQL options

Despite the Operator’s ability to configure PostgreSQL and the large number of Custom Resource options, there may be situations where you need to pass specific options directly to your cluster’s PostgreSQL instances. For this purpose, you can use the PostgreSQL dynamic configuration method provided by Patroni. You can pass PostgreSQL options to Patroni through the Operator Custom Resource, updating it with deploy/cr.yaml configuration file).

Custom PostgreSQL configuration options should be included into the patroni.dynamicConfiguration.postgresql.parameters subsection as follows:

        max_parallel_workers: 2
        max_worker_processes: 2
        shared_buffers: 1GB
        work_mem: 2MB

Please note that configuration changes will be automatically applied to the running instances as soon as you apply Custom Resource changes in a usual way, running the kubectl apply -f deploy/cr.yaml command.

You can apply custom configuration in this way for both new and existing clusters.

Normally, options should be applied to PostgreSQL instances dynamically without restart, except the options with the postmaster context. Changing options which have context=postmaster will cause Patroni to initiate restart of all PostgreSQL instances, one by one. You can check the context of a specific option using the SELECT name, context FROM pg_settings; query to to see if the change should cause a restart or not.


The Operator passes options to Patroni without validation, so there is a theoretical possibility of the cluster malfunction caused by wrongly configured PostgreSQL instances. Also, this configuration method is used for PostgreSQL options only and cannot be applied to change other Patroni dynamic configuration options. It means that options in the parameters subsection under patroni.dynamicConfiguration.postgresql will be applied, and everything else in patroni.dynamicConfiguration.postgresql will be ignored.


PostgreSQL Host-Based Authentication (pg_hba) allows controlling access to the PostgreSQL database based on the IP address or the host name of the connecting host. You can configure pg_hba through the Custom Resource manifest in the spec.patroni.dynamicConfiguration.postgresql.pg_hba section.

      - local   all all trust
      - host    all all md5
      - host    all all ::1/128   md5
      - host    all mytest reject

Get expert help

If you need assistance, visit the community forum for comprehensive and free database knowledge, or contact our Percona Database Experts for professional support and services. Join K8S Squad to benefit from early access to features and “ask me anything” sessions with the Experts.

Last update: 2023-12-08