Preliminary version. The functionality may change, but the basic features will be preserved. Compatibility with future versions is ensured, but may require additional migration actions.

PostgresClass

Cluster Wide PostgresClass resource allows limiting the creation of invalid configurations and predefining some values.
Every Postgres resource must be linked to an existing PostgresClass resource. Before deploying the service, all configuration will be checked against the corresponding PostgresClass.

Topology

Structure that allows managing the distribution of Postgres Managed Service pods in the Kubernetes cluster.

spec:
    topology:
        allowedTopologies:
        - Ignored    # Standard Kubernetes distribution mechanism is used
        - Zonal      # Deployment within a single zone
        - TransZonal # Deployment preferably in different zones
        defaultTopology: "TransZonal"
        allowedZones:
        - zone-1
        - zone-2
        - zone-3

Sizing Policies

Structure that allows creating a set of policies for determining the size of linked Postgres.
This will help avoid uneven distribution of CPU and Memory resources on cluster nodes.
The determining factor for choosing a particular policy is falling within the cores interval.
Then compliance with other fields of the specific policy will be checked.

spec:
  sizingPolicies:
    - cores:
        min: 1
        max: 4
      memory:
        min: 100Mi
        max: 1Gi
        step: 1Mi
      coreFraction: [10, 30, 50] 
    - cores:
        min: 5
        max: 10
      memory:
        min: 500Mi
        max: 2Gi
      coreFraction: [50, 70, 100]

Validation Rules

CEL (Common Expression Language) is used as syntax for creating flexible validation mechanisms. We provide a set of predefined variables that can be used in rule:

  • configuration.maxConnections
  • configuration.workMem
  • configuration.sharedBuffers
  • configuration.walKeepSize
  • instance.memory.size
  • instance.cpu.cores
spec:
  validations:
    - message: "Max connections should not be more than 300"
      rule: "configuration.maxConnections < 300"
    - message: "Shared buffers should not be more than 25% of RAM"
      rule: "configuration.sharedBuffers < instance.memory.size / 4"

Overridable Configuration

Whitelist of configuration parameters that can be overridden in the Postgres resource.
List of all possible parameters.

spec:
  overridableConfiguration:
    - maxConnections
    - workMem

Configuration

Configuration parameters that can be defined at the PostgresClass level.
Values of these parameters will override defaults for all linked Postgres.
Note: Parameters that were allowed and overridden in overridableConfiguration will take priority.

spec:
  configuration:
    maxConnections: 100
    workMem: 100Mi

Defaults that calculates by Postgres Operator will be:

  • maxConnections: 100
  • sharedBuffers: Calculated as 25% (0.25) of the total memory size.
  • workMem: Calculated using the remaining memory after allocating sharedBuffers, distributed across four times the maxConnections.
  • walKeepSize: 512Mi

Affinity

Standard Kubernetes mechanism for managing scheduling of deployed pods.

spec:
  nodeAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
      nodeSelectorTerms:
      - matchExpressions:
        - key: "node.deckhouse.io/group"
          operator: "In"
          values:
          - "pg"

Tolerations

Standard Kubernetes mechanism for managing scheduling of deployed pods.

spec:
  tolerations:
  - key: primary-role
    operator: Equal
    value: pg
    effect: NoSchedule

Node Selector

Standard Kubernetes mechanism for managing scheduling of deployed pods.

  nodeSelector:
    "node.deckhouse.io/group": "pg"

Usage Examples

Basic Usage

apiVersion: managed-services.deckhouse.io/v1alpha1
kind: PostgresClass
metadata:
  labels:
    app.kubernetes.io/name: managed-psql-operator
  name: new
spec:
  topology:
    allowedTopologies:
      - Zonal
      - TransZonal
      - Ignored
    allowedZones: []
    defaultTopology: Ignored
  configuration:
    maxConnections: 300
  overridableConfiguration:
    - maxConnections
    - sharedBuffers
    - walKeepSize
  validations:
    - message: "Max connections should not be more than 100"
      rule: "configuration.maxConnections > 100"
    - message: "Shared buffers should be less that 40% of memory.size"
      rule: "configuration.sharedBuffers * 100 < instance.memory.size * 40"
    - message: "walKeepSize can not be more than 1Gi"
      rule: "configuration.walKeepSize <= 1073741824 "
  sizingPolicies:
    - cores:
        min: 1
        max: 3
      memory:
        min: 1Gi
        max: 5Gi
        step: 1Gi
      coreFractions:
        - 10
        - 20
        - 50
        - 100
    - cores:
        min: 4
        max: 10
      memory:
        min: 5Gi
        max: 15Gi
        step: 1Gi
      coreFractions:
        - 50
        - 100