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:13.2
   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

   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

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

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

                        

Property If not set in YAML, default value Meaning
name   Required.
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 as a given infrastructure can handle as long as each cluster's name is unique.
namespace default Optional.
The namespace where the Kubegres resource will be created and a PostgreSql cluster will be deployed.
annotations   Optional.
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
  Required.
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
  Required.
The name of the Postgres Docker image. Kubegres expects either a Postgres Docker official image or any compatible image.
Consequently, Kubegres operator does not ship with a custom Docker image with obscure set of libraries.
More details about the Postgres docker image: Docker Hub.
spec
 imagePullSecrets
  Optional.
It allows to pull custom Postgres images from a private repo. The images have to be compatible with a Postgres Docker official image.
More details about the type of this field (search for "imagePullSecrets" in that page's table).
spec
 port
5432 Optional.
The port exposed by the Postgres docker container to access to the PostgreSql server.
spec
 database
  size
  Required.
The size of each Postgres Pod's database in a cluster. We use "Mi" for Megabyte and "Gi" for Gigabyte.
spec
 database
  storageClassName
Uses the default Storage-Class defined in a Kubernetes cluster Optional.
It defines the Storage-Class which will be used to store PostgreSql database.
If it is not set, Kubegres operator uses the default Storage-Class available in a Kubernetes cluster.
Behind the scenes, Kubernetes creates a Persistence-Volume-Claim (PVC) for each Postgres Pod and associates it to the given Storage-Class name.
spec
 database
  volumeMount
/var/lib/postgresql/data Optional.
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
base-kubepostgres-config Optional.
It allows setting the name of a ConfigMap which contains the configs files and their contents required by Kubegres.
More details here.
spec
 failover
  isDisabled
false Optional.
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 we do not want Kubegres to automatically failover a Primary or Replica instances during that maintenance.
spec
 failover
  promotePod
  Optional.
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 from 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
  schedule
  Optional.
It schedules a back-up regularly. The cron format follows the standard Cron spec.
More details here.
spec
 backup
  pvcName
  Optional.
The Persistence-Volume-Claim (PVC) defining where the back-up data will be stored. A volume backed by a PVC is mounted into the path defined by "spec.backup.volumeMount" (see below).
More details here.
spec
 backup
  volumeMount
  Optional.
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".
More details here.
spec
 resources
  Optional.
It allows to define the resources requests/limits of CPU and Memory for the Postgres Pods. Its type is of the Kubernetes type ResourceRequirements.
More details here.
spec
 scheduler
  affinity
  Optional.
It allows setting custom Pod/Node affinity policy. Its type is of the Kubernetes type Affinity.
More details here.
spec
 scheduler
  tolerations
  Optional.
It allows setting custom tolerations policy. Its type is an array of the Kubernetes type Toleration.
More details here.
spec
 env
  name
  Required.
The password of the super user "postgres". This user is created by the official PostgreSql docker image.
spec
 env
  name
  Required.
The password of the "replication" user which is used by PostgreSql to replicate data between Primary and Replicas servers.