Blog

Managing Stateful Applications in Kubernetes

Stateful applications, such as database services and message brokers, record and manage the information generated within an enterprise platform. Though Kubernetes has always supported stateless applications—which are horizontally scalable due to the interchangeability of each pod—stateful applications require stronger guarantees for the storage they use.

Why the need for extra guarantees when it comes to stateful vs stateless? Whereas the storage used by stateless containerized applications can simply be re-initialized when a pod is rescheduled to different node in the cluster, stateful applications are recording business-critical information that must be preserved at all costs—that requires persistent storage with an independent lifetime.

In Kubernetes, persistent volumes fill that role, and can be created using a variety of storage provisioners. The actual back-end storage services each provisioner interfaces with is responsible for providing adequate data protection, such as backup/restore and high availability, and other data management features.

With data protection, high availability, and flexible provisioning across the cluster all outside the scope of Kubernetes, what can you do to help ensure those things for your Kubernetes deployments?

In this article, we will look at the options for deploying stateful applications using Kubernetes and discuss the ways in which Cloud Volumes ONTAP and NetApp Trident make it easier to manage, scale, and protect the data storage those applications depend upon.

Stateful Applications in Kubernetes


Kubernetes deployment persistent volumes are used to create a layer of abstraction between pods and their provisioned storage, allowing each to be managed separately. Pods use a persistent volume claim as a request for storage that is matched to a persistent volume by the Kubernetes cluster.

Using a reclaim policy of “retain”, a persistent volume will not be deleted or cleared down after the persistent volume claim is released. Because of this, in the event of a failure or the rescheduling of the pod onto a different node, the relationship between pod and storage can be re-established. Take a look at this example use case of deploying MySQL with WordPress where persistent volumes were used in this way to deploy a database server.

The manual creation of persistent volumes ahead of time is known as static provisioning and requires much more administrative overhead than dynamic provisioning. In dynamic provisioning, the cluster can automatically deploy storage in response to the persistent volume claims it receives. Stateful applications can take advantage of dynamic provisioning by using stateful sets, which use a volume claim template to allocate storage and then permanently bind the resulting persistent volume to the requesting pod. This is more useful for building a cluster of stateful pods, such as for NoSQL database systems like Cassandra.

In both static and dynamic provisioning scenarios, stateful applications have a very real need for reliable storage that is resilient against failure, and data protection features, such as backup and restore. In and of itself, these facilities are not provided by Kubernetes, but are instead delegated to the provisioner used and the storage backend. Users have to find outside solutions, such as Trident and Cloud Volumes ONTAP.

Provisioning Kubernetes Storage with NetApp Trident and Cloud Volumes ONTAP


Data Protection advantages in KubernetesNetApp Trident is a dynamic storage provisioner for Kubernetes that fulfils persistent volume claims using storage managed by Cloud Volumes ONTAP as well as other on-prem NetApp storage systems. By using cloud-native compute and storage infrastructure services, Cloud Volumes ONTAP gives end users some very serious advantages when it comes to data protection and storage management.

Trident provisions new persistent container storage that benefit from all of NetApp’s data management capabilities. Using stateful sets simplifies the deployment of all stateful applications by automating much of the required provisioning and administrative activity. If a pod in a stateful set goes down, Kubernetes will automatically bind a new instantiation of the pod to the dynamically provisioned persistent volume it was previously using.

Cloud Volumes ONTAP is deployable to either AWS storage or Azure storage and delivers:

Conclusion


Stateful applications in Kubernetes require persistent storage with an independent lifecycle from their pods. This can be achieved using persistent volumes directly, however, stateful sets and dynamic provisioning provide a solution that is easier to manage and scale up. Dynamically provisioning storage for stateful sets using Trident and Cloud Volumes ONTAP provides the data protection, high availability, and flexible storage management that is a must for reliably storing enterprise information.

Visit us online to find out more about using Cloud Volumes ONTAP for deploying storage in Kubernetes, or start a free 30-day trial in AWS or Azure.
-