Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Short answer: You normally do not install KubeDB’s PostgreSQL high-availability sidecar yourself. Install KubeDB, create a Postgres custom resource, and let the operator build the database Pod, storage, Services, replication, and coordination components. Depending on the release and enabled features, the Pod may include pg-coordinator, a monitoring exporter, or a user-defined helper container.

Those are different things. The coordinator helps KubeDB manage PostgreSQL roles and failover; an exporter exposes metrics; a custom sidecar is an extension point that you must design and test.

What “Postgres sidecar” means in KubeDB

In Kubernetes, a sidecar is a container running in the same Pod as the main application container. It shares the Pod network namespace and can share volumes, but it has its own process, image, resources, security settings, and lifecycle. If the Pod is restarted, all of its containers are affected.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A sidecar is not automatically a proxy, backup system, replication engine, or failover solution. It consumes CPU and memory, can affect Pod readiness, and must not manipulate PostgreSQL data files unless the design explicitly supports that operation.

#1 Best Overall

In KubeDB, the term commonly refers to three separate components:

  • pg-coordinator: KubeDB’s HA coordination helper in applicable PostgreSQL deployments. KubeDB documents Raft-based coordination to help identify a viable primary and support automatic failover.
  • Monitoring exporter: an optional container used when PostgreSQL monitoring is configured. KubeDB can also create a statistics Service for scraping.
  • Custom sidecar: an auxiliary container supplied through the PostgreSQL Pod template for a specific operational purpose.

Conceptually, a generated Pod may look like this:

PostgreSQL Pod
├── postgres                 # database server
├── pg-coordinator           # HA coordination, when applicable
└── monitoring exporter      # when monitoring is enabled

The exact container list depends on the KubeDB release, PostgreSQL mode, and enabled features. Inspect the live Pod rather than assuming every deployment has the same layout. See KubeDB’s PostgreSQL concept documentation and distributed PostgreSQL overview.

How the coordinator works

The coordinator runs beside PostgreSQL rather than as a separate Deployment. It participates in cluster coordination, helps identify the viable primary, and supports KubeDB’s automatic failover process. Raft-based coordination does not replace PostgreSQL replication: PostgreSQL still replicates WAL and database state, while the coordinator helps manage cluster state and primary selection.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

KubeDB’s failure-recovery documentation says failover generally completes in less than 10 seconds in its documented example. Treat that as a vendor-documented expectation, not a universal SLA. Actual recovery depends on Kubernetes scheduling, storage, health checks, replication state, fencing, networking, and workload behavior. Automatic failover is not the same as backup or disaster recovery.

Prerequisites

  • A working Kubernetes cluster and a configured kubectl.
  • Helm 3 for the documented installation path.
  • A StorageClass that supports the access mode and durability you need.
  • A KubeDB license where required by the selected edition and release.
  • Enough CPU and memory for KubeDB, PostgreSQL, and helper containers.
  • Working cluster DNS and Pod-to-Pod networking.
  • An object-storage target and a validated backup workflow if backups are required.

Installation and licensing vary by edition and release. The examples below use the documentation version v2026.6.19; select a version supported by your environment and keep the chart and documentation versions aligned.

Install KubeDB

A representative version-pinned Helm installation is:

helm upgrade -i kubedb oci://ghcr.io/appscode-charts/kubedb 
  --version v2026.6.19 
  --namespace kubedb 
  --create-namespace 
  --set-file global.license=/path/to/license.txt 
  --wait 
  --burst-limit=10000 
  --debug

The license path is a placeholder. Confirm the correct license, edition, registry access, and installation requirements for your deployment using KubeDB’s Helm installation guide and configuration documentation.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
kubectl get pods -n kubedb
kubectl get crd -l app.kubernetes.io/name=kubedb

Air-gapped clusters additionally require image mirroring and registry configuration.

Create credentials without embedding passwords in the Pod template

Use a Kubernetes Secret referenced by spec.authSecret:

apiVersion: v1
kind: Secret
metadata:
  name: pg-auth
  namespace: demo
type: kubernetes.io/basic-auth
stringData:
  username: postgres
  password: replace-with-a-strong-password

Check the Secret key format required by your selected KubeDB release. KubeDB documents authSecret as the mechanism for PostgreSQL superuser credentials and does not accept attempts to set POSTGRES_USER or POSTGRES_PASSWORD through the PostgreSQL Pod template.

Deploy a single PostgreSQL instance

This illustrative resource uses durable storage and an explicit version:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
apiVersion: kubedb.com/v1
kind: Postgres
metadata:
  name: pg-demo
  namespace: demo
spec:
  version: "13.13"
  authSecret:
    name: pg-auth
  storageType: Durable
  storage:
    accessModes:
      - ReadWriteOnce
    resources:
      requests:
        storage: 5Gi
  deletionPolicy: Halt

13.13 is a documentation example, not a universal recommendation. Choose a version available in the catalog installed with your KubeDB release.

kubectl create namespace demo
kubectl apply -f pg-auth.yaml
kubectl apply -f pg-demo.yaml

kubectl get postgres -n demo
kubectl get pods -n demo
a kubectl describe postgres -n demo pg-demo

Remove the accidental leading a if copying the final command: the correct command is kubectl describe postgres -n demo pg-demo. KubeDB should create the PostgreSQL Pod, storage resources, and database Services. Wait for all required containers to become ready.

Inspect the generated Pod and sidecars

First find the Pod and list its containers:

kubectl get pod -n demo -l 'app.kubernetes.io/name=postgreses.kubedb.com' 
  -o custom-columns='NAME:.metadata.name,READY:.status.containerStatuses[*].ready,CONTAINERS:.spec.containers[*].name'

kubectl get pod -n demo <pod-name> 
  -o jsonpath='{.spec.containers[*].name}{"n"}'

kubectl describe pod -n demo <pod-name>
kubectl get pod -n demo <pod-name> -o yaml

Inspect containers independently:

kubectl logs -n demo <pod-name> -c postgres
kubectl logs -n demo <pod-name> -c pg-coordinator

kubectl get pod -n demo <pod-name> 
  -o jsonpath='{range .status.containerStatuses[*]}{.name}{" ready="}{.ready}{" restartCount="}{.restartCount}{"n"}{end}'

If monitoring is enabled, replace the exporter placeholder with the actual container name. A Pod can be Running while one container is crash-looping or not ready, so check readiness and restart counts for every container.

Deploy an HA PostgreSQL cluster

For a three-replica example:

apiVersion: kubedb.com/v1
kind: Postgres
metadata:
  name: pg-ha
  namespace: demo
spec:
  version: "13.13"
  replicas: 3
  standbyMode: Hot
  streamingMode: Asynchronous
  authSecret:
    name: pg-auth
  storageType: Durable
  storage:
    accessModes:
      - ReadWriteOnce
    resources:
      requests:
        storage: 10Gi
  deletionPolicy: Halt

KubeDB documents hot standby, streaming replication, automatic failover, backups, custom configuration, and monitoring. Asynchronous replication usually reduces write latency but can lose recently committed transactions if the primary fails before replicas receive them. Synchronous modes can improve durability while increasing commit latency or reducing availability when synchronous standbys are unavailable. KubeDB documents settings including remote_write, remote_apply, and on; select them according to your recovery objectives.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check roles and Services:

kubectl get pods -n demo 
  -L kubedb.com/role 
  -l 'app.kubernetes.io/name=postgreses.kubedb.com'

kubectl get svc -n demo

KubeDB documents a primary Service named after the PostgreSQL resource and a replica Service using the -replicas suffix. Confirm actual names and selectors in the live cluster before using them in application manifests.

Test failover safely

Use a non-production cluster and record the current primary, replica state, client behavior, role-change time, Kubernetes events, and logs. Watch role labels with:

watch -n 2 "kubectl get pods -n demo -o jsonpath='{range .items[*]}{.metadata.name} {.metadata.labels.kubedb\.com/role}{"\n"}{end}'"

Then use a controlled failure method appropriate to your test plan. Do not describe the result as a guaranteed recovery time, and do not delete production resources as a casual demonstration. Verify that clients reconnect, the surviving replica is eligible, the Services select the intended role, and there is no split-brain condition.

Enable PostgreSQL monitoring

Monitoring belongs in the Postgres resource’s spec.monitor section when you want KubeDB-managed monitoring:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
spec:
  monitor:
    agent: prometheus.io/operator
    prometheus:
      serviceMonitor:
        labels:
          release: kube-prometheus-stack
        interval: 10s

The label must match the Prometheus Operator installation in your cluster. KubeDB’s monitoring configuration can add an exporter sidecar and a statistics Service. This is separate from monitoring the KubeDB operator itself and from application observability such as query latency, pool saturation, and transaction errors. Enabling a ServiceMonitor does not automatically provide dashboards, alert rules, or performance tuning. See the Prometheus Operator guide.

If metrics do not appear, confirm that the exporter container exists, the statistics Service exists, the ServiceMonitor labels match Prometheus discovery, and network policies permit scraping.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When to add a custom sidecar

KubeDB exposes spec.podTemplate.spec.containers for Pod customization. Appropriate uses may include a proprietary exporter, local connection helper, certificate helper, audit integration, or a narrowly designed archival process. A custom sidecar is not a replacement for pg-coordinator and is not automatically vendor-supported for every workload.

Use the following only as a shape to adapt; the image is intentionally not a deployable product image:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
spec:
  podTemplate:
    spec:
      containers:
        - name: postgres
          resources:
            requests:
              cpu: 500m
              memory: 1Gi
        - name: custom-helper
          image: example.invalid/your-helper:pin-a-real-version
          resources:
            requests:
              cpu: 50m
              memory: 64Mi
          securityContext:
            readOnlyRootFilesystem: true

Preserve KubeDB’s required PostgreSQL container. Use unique DNS-compatible names, pin images by version or digest, define requests and limits, and avoid mounting the PostgreSQL data directory read-write unless explicitly supported. Do not add a helper that changes credentials through forbidden environment variables or duplicates coordinator responsibilities.

Test upgrades, failover, backup, restore, node drains, Pod disruption, image pulls, OOM behavior, and readiness interactions with the helper installed. A sidecar that never becomes ready can block the whole database Pod.

Diagnose common failures

  • Pod runs but is not ready: inspect every container’s readiness, logs, PVC events, and mount errors.
  • Coordinator crash-loops: check its logs, image pulls, resource limits, OOM kills, network policies, and custom mounts.
  • No primary is selected: inspect kubedb.com/role labels, coordinator logs, Pod connectivity, and replication health.
  • Failover stalls: check whether a replica is caught up, whether storage and nodes are available, and whether Kubernetes reports scheduling or volume errors.
  • No metrics: verify the exporter, statistics Service, ServiceMonitor labels, Prometheus discovery, and scrape permissions.
  • Credential changes fail: use spec.authSecret and the release’s documented rotation process.
  • Upgrade fails: confirm the target version is in the KubeDB catalog, back up first, use the documented PostgresOpsRequest workflow, and check extension and client compatibility.
  • Deletion behaves unexpectedly: understand deletionPolicy. Halt preserves resources for controlled recovery; destructive policies such as WipeOut require an explicit backup and restore check.

Backups, security, and production readiness

HA is not backup. Automatic failover does not protect against accidental deletion, corrupted data, malicious changes, or loss of the Kubernetes environment. Configure and validate a backup and restore workflow, such as the appropriate KubeStash PostgreSQL integration, with durable object storage and documented recovery objectives.

  • Use durable storage and test node, volume, and topology failure.
  • Set realistic CPU and memory requests and limits for PostgreSQL and every sidecar.
  • Spread replicas across failure domains where the cluster supports it.
  • Configure PodDisruptionBudgets, network policies, TLS, and least-privilege access.
  • Monitor replication lag, connections, storage, restarts, failovers, and backup success.
  • Test restore, upgrades, extension compatibility, credential rotation, and node drains.
  • Confirm the KubeDB edition, license, support plan, and air-gapped requirements.

KubeDB versus alternatives

KubeDB is a good fit when your platform team already operates Kubernetes and wants database lifecycle management through CRDs, including replication, failover, monitoring, upgrades, and storage configuration. It adds operator reconciliation, generated-resource behavior, release compatibility, licensing, and the complexity of operating databases inside Kubernetes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A managed PostgreSQL service is often preferable when reducing Kubernetes and storage operations matters more than in-cluster control. CloudNativePG, Crunchy Postgres for Kubernetes, and Percona Operator for PostgreSQL are reasonable alternatives when a PostgreSQL-focused ecosystem better matches your team. Compare them using explicit criteria: failover model, backup integration, supported versions, upgrade process, licensing, observability, security, topology controls, and vendor support. Do not assume one is universally superior.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.