This page explains best practices for running databases in containers on GKE. You can use a Deployment to create a set of Kubernetes-managed containerized database instances. You then create a Service to provide access to the database independently of any particular Pod. The Service remains unchanged even if the Pod is moved to a different node.
To access the data in your database instance, you create
a PersistentVolumeClaim (PVC) resource and make it available to your workload.
Databases rely on local disks for persistence. A database that runs as a Service
in a Kubernetes cluster and its database files in a PersistentVolumeClaim is
bound to the lifecycle of the cluster. If the cluster is deleted, the database
is also deleted.
If you are building or deploying a stateful application running in GKE, consider using one of the following deployment options for database instances:
Each of the preceding options has trade-offs, given your business goals and constraints. Use the following table to decide if database deployment on GKE is the right choice for you.
Vertical scaling: You can configure your Pods requests to scale automatically. However, you must ensure that your database application can withstand disruptions when your Pods scale up with vertical Pod autoscaling.
Horizontal scaling: Your database may be able to horizontally scale reads or writes by adding replicas. Whether your database supports horizontal scaling depends on whether it has a single writer or multi-writer architecture. To use horizontal scaling, you may need to update the database configuration, in addition to scaling up the number of replicas.
On Autopilot clusters, you aren't billed for resource reservations, only for resource requests.
On Standard clusters, GKE reserves resources for its own operations. Databases on Standard clusters aren't scaled automatically, so overhead might be high for small Pods.
A PersistentVolumeClaim is scoped to a GKE cluster. This scoping means that when a GKE cluster is deleted, the volume claim is deleted. Any database files in the cluster are also deleted. To guard against accidental loss of the database files, we recommend replication or frequent backup.
You can use Backup for GKE to take snapshots of your application configuration and volume data at periodic intervals. Backup for GKE handles the scheduling of volume backups, managing the backup lifecycle, and restoring of backups to a cluster.
The preceding table provides a discussion of some of the considerations for database deployment. However, the table doesn't include all possible considerations. You also need to consider disaster recovery, connection pooling, and monitoring.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-07-17 UTC.