Red Hat OpenShift brings an environment to simplify harnessing the power of Kubernetes for managing a suite of stateless applications, but applications that maintain state (e.g. databases) often require a little bit more work. Often on teams, there are people dedicated to managing the requirements, configurations, deployment for stateful applications in their production environment and are responsible for the real-time monitoring as well controlling authorization and access to these systems.

The robustness of PostgreSQL from a feature standpoint, as well as its ability to meet the compliance and scale requirements for enterprises, makes it no exception to requiring additional support to run it at scale on OpenShift.

In order to enable enterprises to deploy and maintain PostgreSQL containers at scale, Crunchy Data built an open source PostgreSQL Operator. The PostgreSQL Operator leverages the “Operator” design pattern initially created by the team at CoreOS. Kubernetes Operators extend the Kubernetes API to enable teams to perform their administration tasks at scale.

More specifically, CoreOS defines an Operator as “an application-specific controller that extends the Kubernetes API to create, configure, and manage instances of complex stateful applications on behalf of a Kubernetes user. It builds upon the basic Kubernetes resource and controller concepts but includes domain or application-specific knowledge to automate common tasks.” [1]

Following the release of the Crunchy PostgreSQL Container Suite, Crunchy Data was frequently asked by enterprise customers - “How do we manage thousands of PostgreSQL containers?” The PostgreSQL Operator was designed to address that problem. Initially released in March 2017 and now on version 2.6, the PostgreSQL Operator automates many database management tasks associated with large-scale PostgreSQL operations, including:

  • Provisioning new PostgreSQL clusters
  • Creating PostgreSQL replicas and failover targets
  • Defining which servers and disks a PostgreSQL cluster should be deployed to (“node affinity”) as well as CPU & memory requirements
  • Defining and managing user authorization and access controls across databases
  • Deploying load balancing and performance monitoring to clusters
  • Performing backups and restores as well as minor and major upgrades across databases

and more. Your team can use the PostgreSQL Operator through a series of simple commands that can also be furthered automated through scripts or the Kubernetes API itself. For instance, if you want to create a cluster named “openshift1” with load balancing and monitoring to two replicas that run on your medium tier hardware (this assume you have set up your node labels), you would run the following two commands:

pgo create cluster openshift1 --metrics --pgpool
pgo scale openshift1 --replica-count=2 --node-label=speed=medium

Getting started with the PostgreSQL Operator on OpenShift is easy: the Crunchy Data team has a quickstart script for the Crunchy PostgreSQL Operator on OpenShift that will have you up and running in moments. While there are additional considerations in addition to configuration to securely run a PostgreSQL cluster on OpenShift, this script will allow you to become comfortable with using the PostgreSQL Operator and demonstrate to you the new possibilities of managing your databases at scale.

If you want to learn more about running PostgreSQL on Red Hat OpenShift, we invite you to view our Primed Partner page and encourage you to explore what applications you can deploy on OpenShift!