liveBook · Manning

Database

As explained in Platform Engineering on Kubernetes

A database is an organized data store that supports persistent storage and retrieval of application data.

A database is an organized data store that keeps application data outside a service's pod memory, allowing that data to persist across restarts and be shared by multiple replicas. section 2.4.3

Externalizing state lets Kubernetes distribute requests across replicas without each replica maintaining a separate view of the data. Scaling still requires checking database connection-pool limits. section 2.4.3

Database choices follow the application's data and deployment needs:

  • Use a relational database such as PostgreSQL when the service's data is structured relationally. section 5.1.1
  • Use a NoSQL database such as Redis when it suits the service's stored data; the Agenda service uses Redis while C4P uses PostgreSQL. section 5.1.1
  • Provision databases directly in Kubernetes with Helm Charts, or use a managed cloud service that includes database software, operating-system, hardware, and monitoring costs. section 5.1.1 section 1.1.1

Conference application

The Agenda service stores agenda items in Redis and the Call for Proposals service stores proposals in PostgreSQL. With state outside the pods, multiple Agenda replicas can answer requests while sharing the same application state. section 2.4.3 section 5.1.1

Figure 5.2 Provisioning a new PostgreSQL instance using the PostgreSQL Helm Chart. #1 Install a helm chart into a Namespace inside a Kubernetes Cluster; #2 The chart creates Kubernetes resources such as StatefulSets and Deployments to provision a PostgreSQL instance; #3 A Service needs to connect to the newly created instance, this can be done manually or by referencing a Kubernetes Secret that contains the credentials and details on how to connect.

A PostgreSQL Helm Chart installation creates Kubernetes resources such as StatefulSets and Deployments, then exposes connection details through configuration or a Kubernetes Secret. section 5.1.1

How Platform Engineering on Kubernetes covers it

How deep it goes
Explains persistence, replica sharing, database selection, provisioning, and connection limits, but not database internals.
Examples
Uses Redis for Agenda items, PostgreSQL for proposals, and a PostgreSQL Helm Chart deployed inside a Kubernetes cluster.
What you can do after
Operate/configure persistent stores with Helm Charts and account for database connection limits when scaling services.
How it connects
Connects databases with Kubernetes, stateless services, Redis, PostgreSQL, Helm Charts, StatefulSets, Secrets, and Kafka.

Also explained in

Compare how 24 books explain database →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Platform Engineering on Kubernetes. The section links point to the parts of the book it draws on.