Database containers

Multitenant Database Containers for Modern-Day Applications

intro

Multitenant database containers offer unique ways to handle multiple users, databases, or applications within a single infrastructure. Here’s what you need to know.

Tools used in the tutorial
Tool Description Link
Dbvisualizer DBVISUALIZER
TOP RATED DATABASE MANAGEMENT TOOL AND SQL CLIENT

In today’s increasingly digital world, containerization has already became the cornerstone for many real-world applications. One solution gaining significant traction are multitenant database containers that offer a unique way to handle multiple users, databases, or applications within a single infrastructure while ensuring isolation, security, and scalability.

Let’s learn more about them!

What is Multitenancy and Why is It Important?

On a high level, multitenancy is a single instance of software serving multiple “tenants,” while keeping each the data associated with each tenant separate from other tenants. In other words, it is a single software application that provides solutions to problems to multiple customers while keeping each customer’s data isolated from another customer.

Multitenancy can be thought of as an apartment building: one building may be shared with many tenants, but at the same time, each tenant’s apartment is separate for enhanced privacy.

Benefits of Database Multitenancy

As far as databases are concerned, multitenancy refers to a single database instance being used to store data associated with multiple clients with each client having access to their own, isolated, set of data.

In the database world, multitenancy is generally achieved by using containers. Containers are standalone units of software that bundle an application together with its dependencies and as a result, offer several benefits including portability, scalability, and resource efficiency.

Containers are typically synonymous with Kubernetes and that is not without a reason… These days, Kubernetes has already became the de-facto standard orchestrator for containerized applications helping with deployment, scaling, and management.

In fact, containers are so popular that entire data breach search engines having thousands of data breaches were said to have been built on top of them. That is because containers provide:

  • Efficient resource utilization: By using containers, organizations can optimize the utilization of resources. Since containers often share the underlying OS, they’re more efficient than virtual machines.
  • Automatic scaling: The automatic scaling capabilities of Kubernetes allow containers to automatically scale up or down based on demand. In other words, when a new “tenant” is in place, Kubernetes quickly spins up additional containers and handles increased load without impact on performance.
  • Isolation: If we follow the best practices of running containers on Kubernetes, we can ensure that the data belonging to each “tenant” is isolated from other tenants. Kubernetes has specific features that facilitate that (look into role-based access controls (RBAC) for a start).
  • Simplified management: When using Kubernetes, we can define and version the configurations related to database containers. By doing so, we can simplify the management of our database infrastructure.

Multitenant Database Containers

As such, we come to multitenant database containers. Some developers imagine that multitenant database containers are very hard to provision or maintain but actually that is not the case.

As you can already imagine, with the capabilities of containers we can easily work with databases inside of them because containers provide a portable, consistent, and isolated environment that allows databases to be deployed across any infrastructure with minimal configuration.

To provision a database, you need three things:

  1. Deployment Resource: Defines how the database container runs and keeps it healthy).
  2. Persistent Volume (PV): Stores database data so it survives restarts and redeployments.
  3. Service: Exposes the database with a stable network endpoint for applications.

All of those things accept YAML-based (.yaml) files as configuration options, so what you need to do is to define options inside of YAML files, then tell Kubernetes to use them.

Here is a simple PV configuration:

Copy
        
1 apiVersion: v1 2 kind: PersistentVolume 3 metadata: 4 name: mysql-pv # meaning mysql-persistentvolume 5 spec: # specifications of your server 6 capacity: # we specify the storage underneath 7 storage: 1Gi # 1GB, change this based on your requirements 8 accessModes: # define how a Persistent Volume can be accessed by the pods that use it 9 - ReadWriteOnce 10 # What happens to the PV once a PVC (Persistent Volume Claim) is deleted? 11 persistentVolumeReclaimPolicy: Retain # Options: Retain, Delete 12 hostPath: 13 path: /.../data/mysql # Path to your MySQL data directory

After, ensure you have a Persistent Volume Claim (a PVC for short). This allows your database deployment to request storage from a PV (defined above.) The PVC configuration (also a YAML file) should match the requested size and access modes of the PV. It does not include anything fancy, you would just need to confirm the amount of storage you already defined:

Copy
        
1 apiVersion: v1 2 kind: PersistentVolumeClaim 3 metadata: 4 name: mysql-pvc 5 spec: 6 accessModes: 7 - ReadWriteOnce 8 resources: 9 requests: 10 storage: 1Gi # 1GB. This MUST match the size of your PV

Now, create a database deployment like so:

Copy
        
1 apiVersion: apps/v1 2 kind: Deployment 3 metadata: 4 name: mysql-deployment 5 spec: 6 replicas: 1 # You can scale to multiple replicas if needed 7 selector: 8 matchLabels: 9 app: mysql 10 template: 11 metadata: 12 labels: 13 app: mysql 14 spec: 15 containers: 16 - name: mysql 17 image: mysql:8.0 # Adjust as necessary 18 env: 19 - name: MYSQL_ROOT_PASSWORD 20 value: "password" # You can store passwords via Secrets. If you do, you don't need this 21 - name: MYSQL_DATABASE 22 value: "demo_db" # what database are you connecting to? 23 ports: 24 - containerPort: 3306 # the port of the DBMS. MySQL => 3306 25 volumeMounts: 26 - name: mysql-storage 27 mountPath: /var/lib/mysql # usually /var/lib/mysql unless you defined another dir in my.cnf 28 volumes: 29 - name: mysql-storage 30 persistentVolumeClaim: 31 claimName: mysql-pvc # this must match the name of your PVC (above)

Finally, you need to make your deployment able to communicate with applications inside of Kubernetes by creating a Service. This is also a YAML file (what a surprise, right?) and can be defined like so:

Copy
        
1 apiVersion: v1 2 kind: Service 3 metadata: 4 name: mysql-service 5 spec: 6 selector: 7 app: mysql # This should match the label in your deployment 8 ports: 9 - protocol: TCP 10 port: 3306 # The database port 11 targetPort: 3306 # The port "exposed" by your container. Usually the same

Now that you have all of the necessary configurations, apply them using Kubernetes. Run four commands using kubectl making sure to replace the file names according to the files you’ve created:

Copy
        
1 kubectl apply -f mysql-pv.yaml 2 kubectl apply -f mysql-pvc.yaml 3 kubectl apply -f mysql-deployment.yaml 4 kubectl apply -f mysql-service.yaml

Now you should be good to go. To be sure, verify everything by:

  1. Checking the status of the PV and the PVC by running kubectl get pv|pvc
  2. Checking if the Kubernetes service (svc) actually exists by running kubectl get svc.

If everything is okay, you now know your way around multitenant database containers. Mission complete!

Conclusion

Multitenant database containers may sound scary, but in reality, everything is more simple than it seems. You do need to know your way around Kubernetes and may need to learn how to create configuration files in order to apply and deploy them, but otherwise, everything’s pretty straightforward.

We hope you’ve enjoyed this blog and that you will stay around for more. Stay tuned to the TheTable blog for more database content, and until next time!

FAQ

What are multitenant database containers?

Multitenant database containers are usually deployments of Kubernetes that make a single instance of an application or a database serve multiple distinct “tenants.” Since each tenant has its own isolated environment, the name is appropriate.

How to configure multitenant database containers in Kubernetes?

To configure multitenant database containers in Kubernetes, you will need three things: a Deployment Resource, a Persistent Volume, and a Service. These things should be YAML (.yaml) files and contain the configurations inside each one of them.

Why should I use DbVisualizer?

Consider using SQL clients like the one provided by DbVisualizer because they do not only come with powerful SQL clients facilitating autocomplete operations together with drag-and-drop abilities and the like, but also provide support for the most popular data sources, allow you to export data in a variety of formats, and have the capability to let you edit data as you view it.

Dbvis download link img
About the author
LukasVileikisPhoto
Lukas Vileikis
Lukas Vileikis is an ethical hacker and a frequent conference speaker. He runs one of the biggest & fastest data breach search engines in the world - BreachDirectory.com, frequently speaks at conferences and blogs in multiple places including his blog over at lukasvileikis.com.
The Table Icon
Sign up to receive The Table's roundup
More from the table
Title Author Tags Length Published
title

Using MyDumper Checksums for Reliable MySQL Backup Validation

author Lukas Vileikis tags Backup 6 min 2026-05-07
title

PostgreSQL Backup and Restore: Complete Tutorial with pg_dump and pg_restore

author Leslie S. Gyamfi tags pg_dump POSTGRESQL 9 min 2026-05-04
title

MySQL 8.0 EOL: What Happens Next?

author Lukas Vileikis tags MARIADB MySQL SQL 4 min 2026-04-30
title

Best Tools for Role-Based Access Control (RBAC) in SQL Databases in 2026

author Lukas Vileikis tags SQL SQL clients 6 min 2026-04-27
title

Versioning Your Queries: Git Workflows for Analysts and Engineers

author Lukas Vileikis tags 7 min 2026-04-23
title

The Best MySQL GUI for macOS: Top 4 Alternatives to Workbench

author Leslie S. Gyamfi tags SQL SQL clients 7 min 2026-04-20
title

Choosing the Right SQL Client for Cassandra Clusters

author Lukas Vileikis tags Cassandra 5 min 2026-04-16
title

Best Cross-Platform Database IDEs in 2026

author Lukas Vileikis tags SQL clients 6 min 2026-04-13
title

Database Clients: A Security Comparison of the Most Popular Tools

author Lukas Vileikis tags SQL 5 min 2026-04-09
title

SQL Interview Questions and Answers: Part 2 — Problems & Solutions

author Lukas Vileikis tags MARIADB MySQL SQL 7 min 2026-04-06

The content provided on dbvis.com/thetable, including but not limited to code and examples, is intended for educational and informational purposes only. We do not make any warranties or representations of any kind. Read more here.