Portworx Guided Hands On-Labs. Register Now

puzzle

For a large organization, maintaining software efficiency as data volume rises means increased resource use. Now that the cloud serves as a primary operating space for all types of applications, an unobstructed connection is more vital than ever.

Kubernetes has quickly become a popular solution due to the fact that it’s generally easy to manage, as well as the level of security and many benefits it offers larger enterprises. Kubernetes eliminates downtime associated with app and service management and offers simple, automatic software updates and deployment. Its architecture eliminates the need to manage physical devices and enables us to specify the memory and computing capacity necessary for our applications without concern for the core technology. Furthermore, it has proven highly beneficial for scaling and mobility.

Despite its combination of flexibility and function, it lacked the means to persist data to disk, instead using non-persistent — or ephemeral — storage. Therefore, since most production software is stateful and requires storage, it was initially unknown if databases could run on Kubernetes.

To address these concerns, Kubernetes has more recently added persistent volumes and storage class objects to its storage management repertoire. Since Kubernetes 1.5, StatefulSets have ensured that pods preserve their unique ID even if moved to another system. The application can also persist application data by connecting them to an associated persistent volume. Now, the use of “operators” that connect to Kubernetes enable traditional databases like Cassandra, PostgreSQL, and CockroachDB to integrate seamlessly.

With the diverse range of databases that StatefulSets has made available, it is necessary to compare options based on their overall compatibility with and ability to complement Kubernetes.

Kubernetes Database Best Practices

Before you decide on running a managed database vs. Kubernetes lusters, you should consider a number of factors first.

The most important thing to remember is that Kubernetes is a stateless environment. That means your data is not as permanent as it would be if you stored it in a traditional storage medium. Remember, pods are designed to be removed and restarted when problems arise.

Thus, databases in Kubernetes need to contend with a higher chance of constant failovers and restarts.

Because of this, the best database for Kubernetes is suited for the testing phase. Applications in this development stage typically don’t need to store data permanently, so the transient state of Kubernetes databases wouldn’t be a problem.

If you decide to push ahead with database deployment in Kubernetes, here are a few best practicesto keep in mind.

First, make sure you start with the right database solution. The best database for data on Kubernetes should support features that are friendly to the platform, such as load balancing and maintaining persistent volumes.

As such, your first step is verifying whether these features are working. Build a test database and then stress test it thoroughly. You want to ensure it’s working as best as it possibly can once deployed. This also allows you to verify if your configurations are correct.

Sometimes, the best database for data on Kubernetes is done via operators. This allows you to “wrap” your database and use it more easily with stateful applications.

Also, be mindful of which replication modes you’re using. The best database for data on Kubernetes should allow for both synchronous and asynchronous replication. The former is more reliable but consumes more resources, but the latter has a higher risk of data loss. Be sure you know these risks and how much your application can handle.

Choosing a Database to Complement Kubernetes

This portion of the article examines the compatibility and function of:

  • Cassandra
  • PostgreSQL
  • MongoDB
  • CockroachDB

Cassandra

While Cassandra’s ability to expand and contract as needed is one of its most impressive characteristics, Kubernetes simplifies the management of the lifespan of distributed systems. This makes for a synergistic and natural match between the two technologies. In this relationship, Kubernetes can receive developer preferences to generate and implement the specifications needed to enlarge Cassandra clusters.

Features:

  • Apache Software Foundation project
  • Created with write and read speed as priorities
  • Peer-to-peer architecture (no primary nodes)
  • Supports Structured Query Language (SQL) subtypes like data definition language (DDL) and data manipulation language (DML)
  • Provides drivers for many languages including Python, Go, .NET, and Java

Use Cases:

  • Efficiently manages large quantities of data (as seen in health tracking and weather monitoring applications)
  • Rapid, reliable performance suitable to smart car technologies
  • Broad availability for real-time data delivery (sports scores, election results, and such)
  • Scalability for distributed systems that running on multiple servers (or multiple server nodes)
How Does Cassandra Work with Kubernetes?

The short answer: operators. Instaclustr or DataStax have built operators that connect Cassandra to Kubernetes. Cassandra operators have various advantages, including monitoring support, high-level cluster control using CustomResourceDefinition APIs (CRDs), and full backup instructions.

Cassandra and Kubernetes are both free and open-source. As a result, customers and operators only have to purchase support and services as needed. Furthermore, Kubernetes and Cassandra can run on virtual machines in public cloud, on-premises, hybrid cloud, and multi-cloud environments.

Learn more about Choosing a Kubernetes Operator for Cassandra.

PostgreSQL

PostgreSQL is a database management system that operates on the Linux operating system and interacts with objects in a relational fashion. It is named as such because it uses SQL to retrieve data stored in the database’s tables.

Features:

  • Follows ACID standards
  • Manages multiple versions of a single file
  • Support for user-defined data types
  • Substantial fault tolerance
  • Can store pictures, video, audio, and graphical data

Use Cases:

  • Financial services industry: PostgreSQL efficiently handles OLTP workloads
  • Geometric data: PostGIS is a GIS plugin that offers hundreds of types of geometric data analysis.
  • Manufacturing: Industries that embrace PostgreSQL as a reliable and inexpensive storage backbone can experience rapid innovation and growth. Its automatic fail-over configuration helps provide system updates with minimal downtime.
How Does PostgreSQL Work with Kubernetes?

We can deploy PostgreSQL on Kubernetes with the help of a Postgres operator or a Helm chart. The operator monitors changes to PostgreSQL cluster manifests and configures the clusters according to requirements. Kubernetes also allows for the isolation of other PostgreSQL-based apps running on the same virtual machine or within the same Kubernetes cluster. One of the many ways to profit from the power and efficiency of Postgres is its deployment on Kubernetes.

Learn more about Choosing a Kubernetes Operator for PostgreSQL.

MongoDB

MongoDB is a NoSQL database that stores data as key-value pairs. It is a free and open-source document database that allows for fast data processing, data modeling, and administration in corporate applications. It also supports auto-scaling alongside various operating systems including Windows and Linux.
Features:

  • Scalable and manageable database
  • “Replica set” functionality provides automated fail-over and data redundancy
  • Internal memory stores the working data set, allowing faster data access
  • High-performance data persistence and input and output operations
  • Data modeling simplifies storing complex structures (e.g., hierarchical relationships)

Use Cases:

  • Customer behavior analyses
  • Real-time data integration
  • Product information management
  • Scaling and mobility
  • Internet of things
How Does MongoDB Work with Kubernetes?

The official MongoDB operator is available for use with MongoDB on Kubernetes. It provides specifications of the MongoDB cluster to easily connect with Kubernetes. One advantage of deploying Kubernetes with MongoDB is that it increases the stability of applications. With the appropriate configuration, the MongoDB operator immediately addresses component failure. Furthermore,  each microservice may also access resources based on what is required at the time of the failure.

CockroachDB

CockroachDB is an SQL database based on a key-value pair. Its built-in SQL API is compatible with ACID transactions, which do not require user intervention or additional resources to remain active. As such, we can structure, manipulate, and query data with ease. CockroachDB scales horizontally and can withstand the failure of a single disk or an entire data center.

Features:

  • Cross-cloud migration
  • Support for languages like Java, Python, Ruby, and Go
  • Input and output transparency (distributed transactions)
  • High availability
  • Scaling and repair on an automated basis
  • Open-source

Use Cases:

  • Transaction processing systems used for online financial and sales transactions
  • Distributed database solutions
How Does CockroachDBWork with Kubernetes?

Cockroach Labs created CockroachDB with the Kubernetes container orchestration system in mind. When it comes to Kubernetes, the added job of deploying and managing databases specifically to make app storage compatible can be a time-consuming and burdensome task. The features of CockroachDB, such as symmetrical instances, automatic fail-over, and distributed architecture, make it the perfect choice for Kubernetes-related workloads. Furthermore, their open-source Kubernetes operator can automate deployment and manage the overall Kubernetes cluster.

How Do Kubernetes Operators Simplify the Deployment and Operation of These Databases?

Kubernetes operators develop and run applications both on top of Kubernetes and in the background of its APIs. A single Kubernetes operator enables automation for managing the installation of services. For example, installing the Kubernetes Operator for MongoDB handles the entire lifecycle of that service. It provides the ability to install all the necessary packaging within a single command. Essentially, it does the heavy lifting and simplifies the use of various services with Kubernetes. This allows us to easily extend its capabilities in order to support specific applications and use cases.

Conclusion

Although its dynamic stateless nature has historically presented difficulties for data storage in the Kubernetes environment, the addition of StatefulSets in Kubernetes 1.5 provided the necessary features for managing stateful applications. StatefulSets and persistent volumes allow more traditional database technologies to operate within a Kubernetes environment.

With many available database technologies from which to choose, the ability to complement Kubernetes can be a crucial factor in the decision-making process.

If you are interested in operating database technologies in a Kubernetes environment, you can learn more about data management solutions like Portworx, which can help provide a scalable and secure data layer in a Kubernetes environment

Share
Subscribe for Updates

About Us
Portworx is the leader in cloud native storage for containers.

untitled

Ryan Wallner

Portworx | Technical Marketing Manager
Explore Related Content:
  • databases
  • kubernetes
  • mongodb
  • Portworx Data Services
  • postgresql
link
Revolutionizing Financial Services
July 9, 2024 Technical Insights
Revolutionizing Financial Services with Kubernetes and Portworx: Balancing Innovation...
Arnab Basu
Arnab Basu
link
scenery image
April 8, 2024 Featured
Portworx, Red Hat OpenShift Virtualization, and KubeVirt
Tim Darnell
Tim Darnell
link
Optimizing Red Hat OpenShift
February 28, 2024 Technical Insights
Optimizing Red Hat OpenShift Deployments: Addressing Common Storage Challenges
Andy Gower
Andy Gower