Postgres Deployment Properties

This topic describes the properties you can define in a Postgres operator manifest file.

Synopsis

apiVersion: sql.tanzu.vmware.com/v1
kind: Postgres
metadata:
  name: <string>
spec:
  memory: <memory-limit>
  cpu: <cpu-limit>
  storageClassName: <storage-class>
  storageSize: <size>
  pgConfig:
     dbname: <pg-instance-name>
     username: <pg-username>
  serviceType: <LoadBalancer|ClusterIP>
  highAvailability:
     enabled: <true|false>
  backupLocationSecret:
     name: <backup-secret>

Description

You specify Postgres instance configuration properties to the Postgres operator with a YAML-formatted manifest file. A sample manifest file is provided in pg-instance-example.yaml. The current version of the manifest supports configuring the Postgres instance name, default database name and user name, backup credentials, and memory, cpu, and storage settings for the instance. See also Deploying a New Postgres Instance for information about deploying a new Postgres instance using a manifest file.

Keywords and Values

Instance Metadata

name: <string>
(Required) Sets the name of the Postgres instance. The Postgres operator appends -0 to the end of the name when it creates the instance pod, for example pg-instance-example-0. The new Postgres instance includes a default database with the same name as the instance unless you change the default database name with dbname.

You can filter the output of kubectl commands using this name. For example, if you set the name to pg-instance-example then you can use commands like kubectl get all -l postgres-instance=pg-instance-example or kubectl get pvc -l postgres-instance=pg-instance-example to get all resources or pvc associated with the Postgres instance respectively.

Instance Configuration

memory: <memory-limit>
(Required) The amount of memory allocated to a Postgres instance pod. This value defines a memory limit; if a pod tries to exceed the limit it is removed and replaced by a new pod. You can specify a suffix to define the memory units (for example, 4.5Gi.). If left empty, the default for the Postgres instance is 800 mebibytes, or about 800 megabytes. See Assign Memory Resources to Containers and Pods in the Kubernetes documentation for more information.

cpu: <cpu-limit>
(Required) The amount of CPU resources allocated to a Greenplum pod, specified as a Kubernetes CPU unit (for example, cpu: "1.2"). If left empty, the pod has no upper bound on the CPU resource it can use or inherits the default limit if one is specified in its deployed namespace. See Assign CPU Resources to Containers and Pods in the Kubernetes documentation for more information.

Note: If you do not want to specify a custom cpu limit, comment-out or remove the cpu: keyword from the YAML file, or specify an empty string for its value (cpu: ""). If the keyword appears in the YAML file, you must assign a valid string value to it.

storageClassName: <storage-class>
(Required) The Storage Class name to use for dynamically provisioning Persistent Volumes (PVs) for a Postgres instance pod. If the PVs already exist, either from a previous deployment or because you manually provisioned the PVs, then the Operator uses the existing PVs. You can configure the Storage Class according to your performance needs. See Storage Classes in the Kubernetes documentation to understand the different configuration options.

For best performance, use persistent volumes that are backed by a local SSD with the XFS filesystem, using readahead cache for best performance. Use the mount options rw,nodev,noatime,nobarrier,inode64 to mount the volume. See Creating Local Persistent Volumes for Greenplum for information about manually provisioning local persistent volumes. See Optimizing Persistent Disk and Local SSD Performance in the Google Cloud documentation for information about the performance characteristics of different storage types.

storageSize: <size>
(Required) The storage size of the Persistent Volume Claim (PVC) for a Postgres instance pod. Specify a suffix for the units (for example: 100G, 1T).

dbname: <pg-instance-name>
(Optional) The name of the default Postgres database. By default, the Postgres instance name (name: string) is used as the default database name. See Custom Database Name and User Account.

username: <pg-username>
(Optional) The name of the default Postgres user. By default, “pgadmin” is used as the default user name. See Custom Database Name and User Account.

serviceType: <LoadBalancer|ClusterIP>
(Optional) The Kubernetes publishing service used for the Postgres instance. LoadBalancer is used by default, which exposes the Postgres service externally using the Kubernetes load balancer. ClusterIP uses cluster-internal IP address instead of a load balancer. See Publishing Services (ServiceTypes) in the Kubernetes documentation for more information.

highAvailability: enabled: <true|false>
(Optional) Specifies whether the Postgres instance is created in a single or cluster mode configuration. The default, false, creates single node cluster. See Configuring High Availability for more information about clustered Postgres deployments.

backupLocationSecret: name: <backup-secret>
(Optional) When using a S3-compatible storage location for backups, this value specifies the secret created to securely access the S3 backup location. See Backing Up and Restoring with pgBackRest.