StackGres clusters can be configured in various ways, targeting for example the PostgreSQL configuration, the sizing of the instances, or the connection pooling. The configuration is made in Kubernetes resources such as SGPostgresConfig, SGInstanceProfile, or SGPoolingConfig.

Default Configuration

The StackGres operator creates default configurations in the same namespace as the cluster, if no custom configuration has been specified. These created configuration resources are independent of other clusters configurations, and can be modified by the user without affecting other clusters.

The operator will merge the fields of a custom configuration resource with its default configuration.

If a StackGres cluster is created without specifying custom PostgreSQL configuration (SGPostgresConfig) or resource profile configuration (SgInstanceProfile), the operator applies the default configuration.

Here is the list of default configuration resources that will be created in the same namespace as the cluster:

Name Kind
postgres-<major-version>-generated-from-default-<timestamp> SGPostgresConfig
generated-from-default-<timestamp> SGInstanceProfile
generated-from-default-<timestamp> SGPoolingConfig

You can query the default configuration as follows (for a cluster created in demo):

kubectl -n demo describe sgpgconfig
kubectl -n demo describe sginstanceprofile
kubectl -n demo describe sgpoolconfig

This is an excerpt from the SGPostgresConfig default configuration:

kubectl -n demo describe sgpgconfig
Name:         postgres-14-generated-from-default-1681459078209
Namespace:    demo
Labels:       <none>
Annotations: 1.5.0-SNAPSHOT
API Version:
Kind:         SGPostgresConfig
  Creation Timestamp:  2023-04-14T07:57:58Z
  Generation:          1
  Managed Fields:
    API Version:
    Fields Type:  FieldsV1
  Postgres Version:  14
    autovacuum_max_workers:            3
    autovacuum_vacuum_cost_delay:      2
    autovacuum_work_mem:               512MB
  Default Parameters:
    archive_command:                   /bin/true
    archive_mode:                      on
    autovacuum_max_workers:            3
    autovacuum_vacuum_cost_delay:      2
    autovacuum_work_mem:               512MB
    checkpoint_completion_target:      0.9
    checkpoint_timeout:                15min

Custom Configuration

For creating your custom configuration, check out the following guides:

  • Postgres Configuration

    Details about how the PostgresSQL configuration works and how to customize it.

  • Instance Profile

    An Instance Profile is an abstraction over the resource characteristics of an instance (basically, as of today, CPU “cores” and RAM). StackGres represents such a profile with the CRD SGInstanceProfile. You can think of instance profiles as “t-shirt sizes”, a way to create named t-shirt sizes (such as S, M, L), that you will reference when you create your clusters. It is a way to enforce best practices by using standardized instance sizes.

  • Connection Pooling Configuration

    Details about how to update the pooling configuration.