We’re excited to announce the developer preview of Couchbase Server cluster on Red Hat OpenShift Enterprise which is based on Kubernetes.

This project was a close collaboration between Couchbase, Red Hat, Amadeus and JetStack. A joint session on Deploying Couchbase in Red Hat OpenShift with Kubernetes StatefulSets at Amadeus was delivered at the Red Hat Summit on May 3rd 2017.

Why Couchbase Server is the best fit for Containers and Kubernetes?

Containers echo the industry trend towards Microservice architecture, which implements applications as a series of small, self-contained, loosely coupled software components.  Couchbase Server, with it’s revolutionary multidimensional scaling architecture allows you to treat your database workloads in the same way. With multidimensional scaling (MDS) the database workload is broken into  self-contained, loosely coupled software components such as data, index, query, search and (in-future) analytics services.

The following diagram shows a Couchbase Server cluster with four services running:

  • Data Service – handles core data management operations.
  • Index Service – efficiently maintains indexes for fast query execution.
  • Query Service – handles N1QL query parsing, optimization, and execution. This service interacts with both the indexing service and the data service to process queries and return the results back to the requesting application.
  • Search Service – provides the ability to create full-text search indexes on documents and query them using a variety of indexing methods, text analyzers, and languages.

Multidimensional scaling has three main advantages:

  • Each service can be independently scaled to suit an application’s evolution, whether that entails a growing data set, expanding indexing requirements, or increased query processing needs.
  • You can choose to customize machines to their workloads. For example, by adding more CPUs to a node running queries.
  • Provides workload isolation so that query service does not interfere with index or data services.

How is Couchbase Server running on OpenShift?

Conventional wisdom says you can’t run a database in a container. “Containers are stateless!” they say, and “databases are pointless without state!” That is not true any longer. We just needed the right technology to support database running in a container.

Then came Kubernetes 1.5 which included the new StatefulSet API object (in older versions, StatefulSet was known as PetSet). With StatefulSets, Kubernetes makes it easier to run stateful workloads such as databases. In this developer preview, Couchbase container is implemented using new StatefulSets API object.

Couchbase Server StatefulSets in OpenShift

StatefulSet currently beta in Kubernetes 1.7 & technical preview as of OpenShift 3.5. The StatefulSet provides unique and stable identity and storage to pods, and guarantees deployment order and scaling. This is in contrast to a Deployment or ReplicaSet where pod replicas do not maintain identity across restart/rescheduling and may have the same volume storage properties. Hence, these resources are suited to stateless applications.

Dynamic Volume Provisioning

Dynamic volume provisioning was first introduced in Kubernetes 1.4  & technology preview in Openshift 3.1.1, and now GA in 3.3. This feature enables storage to be dynamically provisioned ‘on-demand’ in a supported cloud environment (e.g. AWS, GCP, OpenStack). The StatefulSet controller automatically creates requests for storage (PersistentVolumeClaim – PVC) per pod, and the storage is provisioned (PersistentVolume – PV). The unique 1-to-1 binding between PV and PVC ensures a pod is always reunited with its same volume, even if scheduled on another node in the instance of failure.

Couchbase Sidecar

By utilizing generic concepts of StatefulSet and dynamic volume provisioning, OpenShift (or Kubernetes) will make sure the right pods are scheduled and running. However, it cannot account for Couchbase Server-specific requirements in its decision making process. For example, registering new nodes when scaling up, rebalancing and also handling migration of data at a scale-down or on node failure. The pod and node events are well-known to OpenShift (or Kubernetes), but the actions required are database-specific.

In this developer preview, Couchbase Server cluster lifecycle operations are built into a sidecar container which is essentially a helper container that sits alongside a standard Couchbase Server container in a pod. The sidecar uses the APIs of OpenShift (or Kubernetes) and Couchbase Server to determine cluster state, and it will safely and appropriately respond to Couchbase Server cluster events, such as scale-up/down and node failure.

For instance, the sidecar can respond to the following events:

  • Scale-up: the sidecar determines whether the node is new to the cluster,  if it’s initialized and joined to the cluster, and then initiates a rebalance.
  • Scale-down: the sidecar executes a pre-container shutdown and safely removes the node from the cluster, rebalancing as necessary.
  • Readiness: the sidecar connects to the local Couchbase Server container and determines its health. The result of the readiness check is used to determine service availability in OpenShift.

What’s available in the Developer Preview?

Let’s take a look at what’s available in this developer preview –

  • Docker container for Couchbase Server 4.6.2 for RHEL.
  • Couchbase Server cluster definitions that have –
    • One Couchbase Server container per pod
    • Couchbase Server service selection (data, index, query)
    • Each Couchbase Server pod type has independent resource specification (CPU, memory)
  • Couchbase Server server groups are automatically configured based on the pod’s failure zone.
  • Couchbase Server container will be gracefully removed from the cluster when the pod count on the StatefulSets is decremented.
  • Documentation

Feedback welcome

As always, we like to hear from you. The feedback of the community and early adopters has a big influence on the direction of the product. Feel free to email me directly at anil@couchbase.com.

References:

Author

Posted by Madhuram Gupta

Leave a reply