Configuration

StackGres clusters can be configured in various ways. In this section we will detail hot to configure the following aspects:

  • the resources requirements of the Pods
  • the PostgreSQL configuration
  • the connection pooling (PgBouncer) configuration.
  • the cluster profile configuration.

The first three configurations listed above (i.e. excluding the profile configuration) are defined in Kubernetes as custom resource definitions (CRDs): SGInstanceProfile, SGPostgresConfig, and SGPoolingConfig. The cluster profile configuration is defined as the SGCluster.spec.profile field.

Cluster Profile

By default an SGCluster is created with the production profile that will enforce some best practices suited for a production environment.

Since the production profile enforce strict rule, that may be inconvenient in a testing or development environment, you may chose any of the other existing profile.

The available profiles are:

  • production: enforces resources requests and limits and add a Pod anti-affinity rules to prevent a Postgres instance to run in the same Kubernetes node.
  • testing: enforces resources limits but disables resources requests and removes the Pod anti-affinity rules that prevents a Postgres instance to run in the same Kubernetes node.
  • development: disables resources requests and limits and removes the Pod anti-affinity rules that prevents a Postgres instance to run in the same Kubernetes node.

The above rules may still be affected by other configurations. Details will can be found in the CRD reference about SGCluster profile.

Default Configuration

The StackGres operator creates default configurations in the same namespace as the cluster, if no custom configuration has been specified using a unique name.

The operator will merge the fields of a custom configuration resource with its 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:

kubectl describe sginstanceprofile
kubectl describe sgpgconfig
kubectl describe sgpoolconfig

Custom Configuration

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

  • Instance Profile Configuration

    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.

  • Postgres Configuration

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

  • Connection Pooling Configuration

    Details about how to update the pooling configuration.