Running PostgreSQL the Kubernetes Way

Gabriele Bartolini

Gabriele Bartolini

May 11, 2022 • 2 minutes
blog image

CloudNativePG is now a public open source project, distributed under the Apache License 2.0, owned and governed by a newly formed community of contributors to the project, founded on solid principles and values inspired by the Cloud Native Computing Foundation (CNCF).

Our goal as a community is to enable students, end users, vendors, and organizations all over the world to run PostgreSQL workloads in Kubernetes, alongside applications.

We’ve made the first step: we set the foundations for a prosperous and healthy community and committed ourselves to go through the CNCF graduation process, having officially submitted our request to join the Sandbox - the first PostgreSQL project to ever do so.

The next step is yours. If you love PostgreSQL and Kubernetes like us, join this community, and contribute at all levels. Read the code of conduct and the CONTRIBUTING section to start with, or, if you want to contribute to the source code, read the developer’s contribution guide.

The source code for CloudNativePG is available in GitHub at github.com/cloudnative-pg/cloudnative-pg.

The first available version of CloudNativePG is 1.15.0, not 1.0, as the project is derived from EDB Cloud Native Postgres, a product that’s been widely deployed in production over the past one and a half years. For this reason, the repository contains a history of over 1400 commits.

CloudNativePG is designed with Kubernetes in mind and it is entirely declarative, following the convention over configuration paradigm. As a result, you can easily install CloudNativePG 1.15.0 in your Kubernetes cluster (even with kind on your local machine) with:

kubectl apply -f \
  https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/main/releases/cnpg-1.15.0.yaml

Once the operator is deployed with the cnpg-controller-manager name in the cnpg-system namespace, you can now create your PostgreSQL cluster with a primary instance and two read replicas, each with 1GB volume from the default storage class, with the following YAML file (angus.yaml):

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: angus
spec:
  instances: 3
  storage:
    size: 1Gi

You can install it with kubectl apply -f angus.yaml, as with any other Kubernetes manifest.

For more information, please refer to the documentation for version 1.15.0. Alternatively, reach out to us on Slack or use GitHub discussions.

If you are physically in Valencia for KubeCon Europe 2022, come and say hello to us!

Don’t forget to start following us on Twitter and … add a star to the project now! Thank you!