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:16.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 probe: livenessProbe: exec: command: - sh - -c - exec pg_isready -U postgres -h $POD_IP failureThreshold: 10 initialDelaySeconds: 60 periodSeconds: 20 successThreshold: 1 timeoutSeconds: 15 readinessProbe: exec: command: - sh - -c - exec pg_isready -U postgres -h $POD_IP failureThreshold: 3 initialDelaySeconds: 5 periodSeconds: 5 successThreshold: 1 timeoutSeconds: 3 env: - name: POSTGRES_PASSWORD valueFrom: secretKeyRef: name: mySecretResource key: superUserPassword - name: POSTGRES_REPLICATION_PASSWORD valueFrom: secretKeyRef: name: mySecretResource key: replicationUserPassword
Property | Meaning | ||||||
---|---|---|---|---|---|---|---|
metadata | |||||||
name |
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 |
The namespace where the Kubegres resource will be created and a PostgreSql cluster will be deployed. |
||||||
annotations |
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 |
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 |
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 |
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 |
The port exposed by the Postgres docker container. |
||||||
spec database |
|||||||
spec database size |
The size of each Postgres Pod's database in a cluster. We use "Mi" for Megabyte and "Gi" for Gigabyte. |
||||||
spec database storageClassName |
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 |
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 |
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 |
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 |
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 |
It expects a Cron format defining how often a back-up should happen. More details about how to enable backup. |
||||||
spec backup pvcName |
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 |
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 |
A security context defines privilege and access control settings for a Pod or Container. More details about Security Context. |
||||||
spec resources |
|||||||
spec resources |
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 |
It allows setting custom Pod/Node affinity policy. More details about affinity and anti-affinity. |
||||||
spec scheduler tolerations |
It allows setting custom tolerations policy. More details about taints and tolerations. |
||||||
spec volume |
|||||||
spec volume volumes |
It allows declaring one or many volumes which can be mounted in the Postgres container(s). More details about Volumes. |
||||||
spec volume volumeMounts |
It allows mounting one or many volumes in the Postgres container(s). More details about VolumeMounts. |
||||||
spec volume 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 probe |
|||||||
spec probe livenessProbe |
Kubernetes uses liveness probes to know when to restart a container. More details about LivenessProbe. |
||||||
spec probe readinessProbe |
Kubernetes uses readiness probes to know when a container is ready to start accepting traffic. More details about ReadinessProbe. |
||||||
spec env |
|||||||
spec env name |
The password of the super user "postgres". This user is created by the official PostgreSql docker image. |
||||||
spec env name |
The password of the "replication" user which is used by PostgreSql to replicate data between Primary and Replicas servers. |
||||||
spec env ... |
You can add any custom environment variable(s) which will be set to the Pod(s). |