All properties explained

The "Kubegres" API types are available in GitHub.

Kubegres uses predefined templates to create Kubernetes resources. Those templates are available in GitHub.

Please see below a Kubegres resource YAML containing all available properties with example values, followed by a table explaining the meaning of each property:

apiVersion: kubegres.reactive-tech.io/v1
kind: Kubegres
metadata:
  name: mypostgres
  namespace: default
  annotations:
    imageregistry: "https://hub.docker.com/"
    nginx.ingress.kubernetes.io/affinity: cookie

spec:

   replicas: 3
   image: postgres:14.1
   port: 5432

   imagePullSecrets:
      - name: my-private-docker-repo-secret

   database:
      size: 200Mi
      storageClassName: standard
      volumeMount: /var/lib/postgresql/data

   customConfig: mypostgres-conf

   failover:
      isDisabled: false
      promotePod: "mypostgres-2-0"

   backup:
      schedule: "* */1 * * *"
      pvcName: my-backup-pvc
      volumeMount: /var/lib/backup

   securityContext:
      runAsNonRoot: true
      runAsUser: 999
      fsGroup: 999
      ...

   resources:
      limits:
         memory: "4Gi"
         cpu: "1"
      requests:
         memory: "2Gi"
         cpu: "1"

   scheduler:
      affinity:
         podAntiAffinity:
            preferredDuringSchedulingIgnoredDuringExecution:
               - weight: 100
                 podAffinityTerm:
                    labelSelector:
                       matchExpressions:
                         - key: app
                           operator: In
                           values:
                           - postgres-name
                    topologyKey: "kubernetes.io/hostname"
      tolerations:
         - key: group
           operator: Equal
           value: critical

   volume:
      volumes:
         - name: dshm
           emptyDir:
             medium: Memory
             sizeLimit: "600Mi"

      volumeMounts:
         - mountPath: /dev/shm
           name: dshm
         - mountPath: /dev/anything
           name: anyMount

      volumeClaimTemplates:
         name: anyMount
         spec:
            accessModes: [ "ReadWriteOnce" ]
            storageClassName: standard
            resources:
              requests:
              storage: 1Gi

   env:
      - name: POSTGRES_PASSWORD
        valueFrom:
           secretKeyRef:
              name: mySecretResource
              key: superUserPassword

      - name: POSTGRES_REPLICATION_PASSWORD
        valueFrom:
           secretKeyRef:
              name: mySecretResource
              key: replicationUserPassword

                        

Property Meaning
metadata
name
Is required: Yes
Type: string

The unique name of a Kubegres resource in Kubernetes. It defines the unique name of a PostgreSql cluster, which is "mypostgres" for this example.
Kubegres operator allows creating as many clusters of Postgres as a given infrastructure can handle as long as each cluster's name is unique.
namespace
Is required: No
Default value: default
Type: string

The namespace where the Kubegres resource will be created and a PostgreSql cluster will be deployed.
annotations
Is required: No
Type: map[string]string

The annotations to pass to the created Pods and StatefulSets. We can set as many annotations as needed.
As an example, in the YAML above we set the annotations:
- imageregistry: "https://hub.docker.com/
- nginx.ingress.kubernetes.io/affinity: cookie
spec
 replicas
spec
 replicas
Is required: Yes
Type: int32

It defines the number of PostgreSql instances (or Pods) to deploy in a cluster.
For example, if set to '3', Kubegres deploys 1 Primary Pod and 2 Replica Pods. If set to '1', it will only create 1 Primary Pod without creating any Replica Pods.
spec
 image
spec
 image
Is required: Yes
Type: string

The name of the Postgres Docker image. Kubegres operator does not ship with a custom Docker image. It expects either a Postgres Docker official image (version 12.4 or higher) or any compatible image.

More details about Postgres Docker image.
spec
 imagePullSecrets
spec
 imagePullSecrets
Is required: No
Type: Array of LocalObjectReference

It allows pulling custom Postgres images from a private repo. The images have to be compatible with a Postgres Docker official image (version 12.4 or higher).

More details about ImagePullSecrets
spec
 port
spec
 port
Is required: No
Default value: 5432
Type: int32

The port exposed by the Postgres docker container.
spec
 database
spec
 database
  size
Is required: Yes
Type: string

The size of each Postgres Pod's database in a cluster. We use "Mi" for Megabyte and "Gi" for Gigabyte.
spec
 database
  storageClassName
Is required: No
Default value: The name of the default Storage-Class in the Kubernetes cluster
Type: string

It allows setting the Storage-Class' name which will be used to store the PostgreSql database.
If it is not set, Kubegres operator uses the default Storage-Class available in a Kubernetes cluster.
Once the Storage-Class is assigned, Kubernetes automatically provisions a PV and a PVC for each Postgres Pod using the Storage-Class.
spec
 database
  volumeMount
Is required: No
Default value: /var/lib/postgresql/data
Type: string

It defines the path in the Postgres container where the database folder 'pgdata' is mounted. The mount will be physically located in the volume (PVC) backed by a Storage-Class (as defined in the above field 'database.storageClassName').
spec
 customConfig
spec
 customConfig
Is required: No
Default value: base-kubepostgres-config
Type: string

It allows setting the name of a ConfigMap which contains the configs files and their contents required by Kubegres.

More details about how to override the default config.
spec
 failover
spec
 failover
  isDisabled
Is required: No
Default value: false
Type: bool

It disables the automatic failover feature for a cluster of PostgreSql.
If it is set to true and if a Primary or Replica PostgreSql instance is not available then Kubegres will not attempt to failover and fix the cluster.
This option can be useful when manually maintaining a node (e.g. restarting it, patching it, ...) and when we do not want Kubegres to automatically failover a Primary or Replica instances during a maintenance.
spec
 failover
  promotePod
Is required: No
Type: string

It allows to manually promote a Replica PostgreSql Pod as a Primary Pod.
It expects the name of a Replica Pod that we would like to promote as a Primary.
This option is independent of the value of the above field "failover.isDisabled". It is always possible to manually promote a Pod, whether "failover.isDisabled" is set to true or to false.
spec
 backup
spec
 backup
  schedule
Is required: No
Type: string

It expects a Cron format defining how often a back-up should happen.

More details about how to enable backup.
spec
 backup
  pvcName
Is required: No
Type: string

The Persistence-Volume-Claim (PVC) defining where the back-up data will be stored. A volume backed by a PVC is mounted on the path defined by "spec.backup.volumeMount" (see the next field).

More details about how to enable backup.
spec
 backup
  volumeMount
Is required: No
Type: string

The location where the backup is stored in the docker image. A volume is mounted on that path using the PVC name defined by "spec.database.pvcName" (see the previous field).

More details about how to enable backup.
spec
 securityContext
spec
 securityContext
Is required: No
Type: PodSecurityContext

A security context defines privilege and access control settings for a Pod or Container.

More details about Security Context.
spec
 resources
spec
 resources
Is required: No
Type: ResourceRequirements

It allows to define the resources requests/limits of CPU and Memory for the Postgres Pods.

More details about managing the resources for containers.
spec
 scheduler
spec
 scheduler
  affinity
Is required: No
Type: Affinity

It allows setting custom Pod/Node affinity policy.

More details about affinity and anti-affinity.
spec
 scheduler
  tolerations
Is required: No
Type: Toleration

It allows setting custom tolerations policy.

More details about taints and tolerations.
spec
 volume
spec
 volume
  volumes
Is required: No
Type: Array of Volume

It allows declaring one or many volumes which can be mounted in the Postgres container(s).

More details about Volumes.
spec
 volume
  volumeMounts
Is required: No
Type: Array of VolumeMount

It allows mounting one or many volumes in the Postgres container(s).

More details about VolumeMounts.
spec
 volume
  volumeClaimTemplates
Is required: No
Type: Array of VolumeClaimTemplates

It allows to automatically provision one or many volumes in the Postgres container(s) using the storage class' provisioner.

More details about VolumeClaimTemplates in a StatefulSet.
spec
 env
spec
 env
  name
Is required: Yes
Type: string

The password of the super user "postgres". This user is created by the official PostgreSql docker image.
spec
 env
  name
Is required: Yes
Type: string

The password of the "replication" user which is used by PostgreSql to replicate data between Primary and Replicas servers.
spec
 env
  ...
Is required: No
Type: Array of EnvVar

You can add any custom environment variable(s) which will be set to the Pod(s).