postgresql
CloudNativePG PostgreSQL operator
@r8s/crds/postgresql
Declared Operator
cnpg
version 1.27.0
Components (3)
Cluster
Render a Cluster (postgresql.cnpg.io/v1) exactly as defined by its CRD.
import { ClusterComponent } from '@r8s/crds/postgresql'
<ClusterComponent
metadata={{ name: 'app-db', namespace: 'default' }}
spec={{
instances: 3,
storage: { size: '10Gi' },
bootstrap: { initdb: { database: 'app' } },
}}
/>
import { ClusterComponent, ScheduledBackupComponent } from '@r8s/crds/postgresql'
<>
<ClusterComponent
metadata={{ name: 'prod-db', namespace: 'default' }}
spec={{
instances: 3,
storage: { size: '50Gi' },
bootstrap: { initdb: { database: 'app' } },
backup: { barmanObjectStore: { destinationPath: 's3://backups/' } },
}}
/>
<ScheduledBackupComponent
metadata={{ name: 'prod-db-backup', namespace: 'default' }}
spec={{
schedule: '0 2 * * *',
cluster: { name: 'prod-db' },
}}
/>
</>
import { ClusterComponent, PoolerComponent } from '@r8s/crds/postgresql'
<>
<ClusterComponent
metadata={{ name: 'app-db', namespace: 'default' }}
spec={{
instances: 3,
storage: { size: '10Gi' },
bootstrap: { initdb: { database: 'app' } },
}}
/>
<PoolerComponent
metadata={{ name: 'app-db-pooler', namespace: 'default' }}
spec={{
cluster: { name: 'app-db' },
instances: 2,
type: 'rw',
pgbouncer: { poolMode: 'transaction' },
}}
/>
</>
"affinity"AffinityOptional—Affinity/Anti-affinity rules for Pods
"backup"BackupOptional—The configuration to be used for backups
"bootstrap"BootstrapOptional—Instructions to bootstrap this cluster
"certificates"CertificatesOptional—The configuration for the CA and related certificates
"description"stringOptional—Description of this PostgreSQL cluster
"enablePDB"booleanOptional—Manage the PodDisruptionBudget resources within the cluster. When configured as true (default setting), the pod disruption budgets will safeguard the primary node from being terminated. Conversely, setting it to false will result in the absence of any PodDisruptionBudget resource, permitting the shutdown of all nodes hosting the PostgreSQL cluster. This latter configuration is advisable for any PostgreSQL cluster employed for development/staging purposes.
"enableSuperuserAccess"booleanOptional—When this option is enabled, the operator will use the SuperuserSecret to update the postgres user password (if the secret is not present, the operator will automatically create one). When this option is disabled, the operator will ignore the SuperuserSecret content, delete it when automatically created, and then blank the password of the postgres user by setting it to NULL. Disabled by default.
"env"EnvItem[]Optional—Env follows the Env format to pass environment variables to the pods created in the cluster
"envFrom"EnvFromItem[]Optional—EnvFrom follows the EnvFrom format to pass environment variables sources to the pods to be used by Env
"ephemeralVolumeSource"EphemeralVolumeSourceOptional—EphemeralVolumeSource allows the user to configure the source of ephemeral volumes.
"ephemeralVolumesSizeLimit"EphemeralVolumesSizeLimitOptional—EphemeralVolumesSizeLimit allows the user to set the limits for the ephemeral volumes
"externalClusters"ExternalClustersItem[]Optional—The list of external clusters which are used in the configuration
"failoverDelay"numberOptional—The amount of time (in seconds) to wait before triggering a failover after the primary PostgreSQL instance in the cluster was detected to be unhealthy
"imageCatalogRef"ImageCatalogRefOptional—Defines the major PostgreSQL version we want to use within an ImageCatalog
"imageName"stringOptional—Name of the container image, supporting both tags (<image>:<tag>) and digests for deterministic and repeatable deployments (<image>:<tag>@sha256:<digestValue>)
"imagePullPolicy"stringOptional—Image pull policy. One of Always, Never or IfNotPresent. If not defined, it defaults to IfNotPresent. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images
"imagePullSecrets"ImagePullSecretsItem[]Optional—The list of pull secrets to be used to pull the images
"inheritedMetadata"InheritedMetadataOptional—Metadata that will be inherited by all objects related to the Cluster
"instances"numberRequired—Number of instances required in the cluster
"livenessProbeTimeout"numberOptional—LivenessProbeTimeout is the time (in seconds) that is allowed for a PostgreSQL instance to successfully respond to the liveness probe (default 30). The Liveness probe failure threshold is derived from this value using the formula: ceiling(livenessProbe / 10).
"logLevel""error" | "warning" | "info" | "debug" | "trace"Optional—The instances' log level, one of the following values: error, warning, info (default), debug, trace
"managed"ManagedOptional—The configuration that is used by the portions of PostgreSQL that are managed by the instance manager
"maxSyncReplicas"numberOptional—The target value for the synchronous replication quorum, that can be decreased if the number of ready standbys is lower than this. Undefined or 0 disable synchronous replication.
"minSyncReplicas"numberOptional—Minimum number of instances required in synchronous replication with the primary. Undefined or 0 allow writes to complete when no standby is available.
"monitoring"MonitoringOptional—The configuration of the monitoring infrastructure of this cluster
"nodeMaintenanceWindow"NodeMaintenanceWindowOptional—Define a maintenance window for the Kubernetes nodes
"plugins"PluginsItem[]Optional—The plugins configuration, containing any plugin to be loaded with the corresponding configuration
"postgresGID"numberOptional—The GID of the postgres user inside the image, defaults to 26
"postgresUID"numberOptional—The UID of the postgres user inside the image, defaults to 26
"postgresql"PostgresqlOptional—Configuration of the PostgreSQL server
"primaryUpdateMethod""switchover" | "restart"Optional—Method to follow to upgrade the primary server during a rolling update procedure, after all replicas have been successfully updated: it can be with a switchover (switchover) or in-place (restart - default)
"primaryUpdateStrategy""unsupervised" | "supervised"Optional—Deployment strategy to follow to upgrade the primary server during a rolling update procedure, after all replicas have been successfully updated: it can be automated (unsupervised - default) or manual (supervised)
"priorityClassName"stringOptional—Name of the priority class which will be used in every generated Pod, if the PriorityClass specified does not exist, the pod will not be able to schedule. Please refer to https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass for more information
"probes"ProbesOptional—The configuration of the probes to be injected in the PostgreSQL Pods.
"projectedVolumeTemplate"ProjectedVolumeTemplateOptional—Template to be used to define projected volumes, projected volumes will be mounted under /projected base folder
"replica"ReplicaOptional—Replica cluster configuration
"replicationSlots"ReplicationSlotsOptional—Replication slots management configuration
"resources"Resources2Optional—Resources requirements of every generated Pod. Please refer to https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ for more information.
"schedulerName"stringOptional—If specified, the pod will be dispatched by specified Kubernetes scheduler. If not specified, the pod will be dispatched by the default scheduler. More info: https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/
"seccompProfile"SeccompProfileOptional—The SeccompProfile applied to every Pod and Container. Defaults to: RuntimeDefault
"serviceAccountTemplate"ServiceAccountTemplateOptional—Configure the generation of the service account
"smartShutdownTimeout"numberOptional—The time in seconds that controls the window of time reserved for the smart shutdown of Postgres to complete. Make sure you reserve enough time for the operator to request a fast shutdown of Postgres (that is: stopDelay - smartShutdownTimeout). Default is 180 seconds.
"startDelay"numberOptional—The time in seconds that is allowed for a PostgreSQL instance to successfully start up (default 3600). The startup probe failure threshold is derived from this value using the formula: ceiling(startDelay / 10).
"stopDelay"numberOptional—The time in seconds that is allowed for a PostgreSQL instance to gracefully shutdown (default 1800)
"storage"Storage2Optional—Configuration of the storage of the instances
"superuserSecret"SuperuserSecretOptional—The secret containing the superuser password. If not defined a new secret will be created with a randomly generated password
"switchoverDelay"numberOptional—The time in seconds that is allowed for a primary PostgreSQL instance to gracefully shutdown during a switchover. Default value is 3600 seconds (1 hour).
"tablespaces"TablespacesItem[]Optional—The tablespaces configuration
"topologySpreadConstraints"TopologySpreadConstraintsItem[]Optional—TopologySpreadConstraints specifies how to spread matching pods among the given topology. More info: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/
"walStorage"WalStorage2Optional—Configuration of the storage for PostgreSQL WAL (Write-Ahead Log)
Pooler
Render a Pooler (postgresql.cnpg.io/v1) exactly as defined by its CRD.
import { ClusterComponent, PoolerComponent } from '@r8s/crds/postgresql'
<>
<ClusterComponent
metadata={{ name: 'app-db', namespace: 'default' }}
spec={{
instances: 3,
storage: { size: '10Gi' },
bootstrap: { initdb: { database: 'app' } },
}}
/>
<PoolerComponent
metadata={{ name: 'app-db-pooler', namespace: 'default' }}
spec={{
cluster: { name: 'app-db' },
instances: 2,
type: 'rw',
pgbouncer: { poolMode: 'transaction' },
}}
/>
</>
"cluster"Cluster2Required—This is the cluster reference on which the Pooler will work. Pooler name should never match with any cluster name within the same namespace.
"deploymentStrategy"DeploymentStrategyOptional—The deployment strategy to use for pgbouncer to replace existing pods with new ones
"instances"numberOptional—The number of replicas we want. Default: 1.
"monitoring"Monitoring2Optional—The configuration of the monitoring infrastructure of this pooler. Deprecated: This feature will be removed in an upcoming release. If you need this functionality, you can create a PodMonitor manually.
"pgbouncer"PgbouncerRequired—The PgBouncer configuration
"serviceTemplate"ServiceTemplateOptional—Template for the Service to be created
"template"TemplateOptional—The template of the Pod to be created
"type""rw" | "ro" | "r"Optional—Type of service to forward traffic to. Default: rw.
ScheduledBackup
Render a ScheduledBackup (postgresql.cnpg.io/v1) exactly as defined by its CRD.
import { ClusterComponent, ScheduledBackupComponent } from '@r8s/crds/postgresql'
<>
<ClusterComponent
metadata={{ name: 'prod-db', namespace: 'default' }}
spec={{
instances: 3,
storage: { size: '50Gi' },
bootstrap: { initdb: { database: 'app' } },
backup: { barmanObjectStore: { destinationPath: 's3://backups/' } },
}}
/>
<ScheduledBackupComponent
metadata={{ name: 'prod-db-backup', namespace: 'default' }}
spec={{
schedule: '0 2 * * *',
cluster: { name: 'prod-db' },
}}
/>
</>
"backupOwnerReference""none" | "self" | "cluster"Optional—Indicates which ownerReference should be put inside the created backup resources.
- none: no owner reference for created backup objects (same behavior as before the field was introduced)
- self: sets the Scheduled backup object as owner of the backup
- cluster: set the cluster as owner of the backup
"cluster"Cluster2Required—The cluster to backup
"immediate"booleanOptional—If the first backup has to be immediately start after creation or not
"method""barmanObjectStore" | "volumeSnapshot" | "plugin"Optional—The backup method to be used, possible options are barmanObjectStore, volumeSnapshot or plugin. Defaults to: barmanObjectStore.
"online"booleanOptional—Whether the default type of backup with volume snapshots is online/hot (true, default) or offline/cold (false) Overrides the default setting specified in the cluster field '.spec.backup.volumeSnapshot.online'
"onlineConfiguration"OnlineConfigurationOptional—Configuration parameters to control the online/hot backup with volume snapshots Overrides the default settings specified in the cluster '.backup.volumeSnapshot.onlineConfiguration' stanza
"pluginConfiguration"PluginConfigurationOptional—Configuration parameters passed to the plugin managing this backup
"schedule"stringRequired—The schedule does not follow the same format used in Kubernetes CronJobs as it includes an additional seconds specifier, see https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format
"suspend"booleanOptional—If this backup is suspended or not
"target""primary" | "prefer-standby"Optional—The policy to decide which instance should perform this backup. If empty, it defaults to cluster.spec.backup.target. Available options are empty string, primary and prefer-standby. primary to have backups run always on primary instances, prefer-standby to have backups run preferably on the most updated standby, if available.