liveBook · Manning

CloudNativePG

As explained in Acing the Certified Kubernetes Administrator Exam, Second Edition

CloudNativePG is an open-source Kubernetes operator for automating the management of PostgreSQL databases.

CloudNativePG is an open-source Kubernetes operator that automates PostgreSQL management, including creation, scaling, backup, and healing. It combines custom resource definitions with a controller, exposing PostgreSQL operations through Kubernetes resources. section 5.4

Use CloudNativePG through three operational layers:

  • Install the operator and its PostgreSQL-related CRDs, which add resources such as clusters, backups, databases, and scheduled backups. section 5.4.2
  • Distinguish a CRD from a custom resource: the CRD defines a resource type, while a CR is an instance created from that definition. section 5.4.3
  • Verify the controller Deployment and inspect the resulting PostgreSQL cluster with kubectl. section 5.4.3

Create and verify a PostgreSQL cluster

Apply a Cluster custom resource with apiVersion postgresql.cnpg.io/v1, one instance, and 1Gi of storage: kubectl apply -f postgres-cluster.yaml. Then run kubectl get cluster my-postgres-cluster and kubectl get pods; successful output shows a healthy cluster and a Running PostgreSQL pod. section 5.4.3

root@kind-control-plane:/# kubectl apply --server-side -f https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-
1.26/releases/cnpg-1.26.1.yaml

namespace/cnpg-system serverside-applied
customresourcedefinition.apiextensions.k8s.io/backups.postgresql.cnpg.io 
serverside-applied
customresourcedefinition.apiextensions.k8s.io/clusterimagecatalogs.postgres
ql.cnpg.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/clusters.postgresql.cnpg.io 
serverside-applied
customresourcedefinition.apiextensions.k8s.io/databases.postgresql.cnpg.io 
serverside-applied
customresourcedefinition.apiextensions.k8s.io/imagecatalogs.postgresql.cnpg
.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/poolers.postgresql.cnpg.io 
serverside-applied
customresourcedefinition.apiextensions.k8s.io/publications.postgresql.cnpg. 
io serverside-applied

Review the server-side installation output to identify the cnpg-system namespace and the PostgreSQL CRDs installed by CloudNativePG. section 5.4.2

How Acing the Certified Kubernetes Administrator Exam, Second Edition covers it

How deep it goes
Explains installation, CRD-versus-CR roles, Cluster configuration, and kubectl verification, but not database administration internals.
Examples
Uses a Cluster manifest with one instance and 1Gi storage, then checks the Deployment, cluster status, and PostgreSQL pod.
What it assumes
Assumes basic Kubernetes resource and kubectl knowledge while teaching operators, CRDs, CRs, and their one-to-many relationship.
What you can do after
Operate/configure a PostgreSQL cluster by installing CloudNativePG, applying a Cluster resource, and verifying healthy Kubernetes results.
How it connects
Connects Kubernetes operators, custom resource definitions, custom resources, controllers, PostgreSQL, Helm, and kubectl.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Certified Kubernetes Administrator Exam, Second Edition. The section links point to the parts of the book it draws on.