VOOZH about

URL: https://thenewstack.io/tutorial-deploy-postgresql-on-kubernetes-running-the-openebs-storage-engine/

⇱ Tutorial: Deploy PostgreSQL on Kubernetes Running the OpenEBS Storage Engine - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2020-03-20 08:12:33
Tutorial: Deploy PostgreSQL on Kubernetes Running the OpenEBS Storage Engine
tutorial,
Cloud Native Ecosystem / Kubernetes / Storage

Tutorial: Deploy PostgreSQL on Kubernetes Running the OpenEBS Storage Engine

In the last part of this series, I covered the steps to install OpenEBS on the Amazon Elastic Kubernetes Service (Amazon EKS). In this tutorial, we will deploy a highly available instance of PostgreSQL.
Mar 20th, 2020 8:12am by Janakiram MSV
👁 Featued image for: Tutorial: Deploy PostgreSQL on Kubernetes Running the OpenEBS Storage Engine
Feature image via Pixabay.

In the last part of this series, I covered the steps to install OpenEBS on the Amazon Elastic Kubernetes Service (Amazon EKS). In this tutorial, we will deploy a highly available instance of PostgreSQL.

Create a Storage Class for PostgreSQL

We will first create a storage class based on the storage pool claim configured in the last tutorial.

 kubectl get spc

👁 Image

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
 name: cstor-sc
 annotations:
 openebs.io/cas-type: cstor
 cas.openebs.io/config: |
 - name: StoragePoolClaim
 value: "cstor-disk-pool"
 - name: ReplicaCount
 value: "3"
provisioner: openebs.io/provisioner-iscsi

The ReplicaCount key will ensure that the data is written across three nodes to add redundancy.

kubectl apply -f cstor-sc.yaml 
kubectl get sc

👁 Image

Deploying PostgreSQL through a Helm Chart

We will now deploy PostgreSQL backed by OpenEBS. By pointing the persistence.storageClass to the cStor storage class created in the last step, the deployment will dynamically create a Persistent Volume (PV) and Persistent Volume Claim (PVC)

helm update
helm install demo stable/postgresql \
--set persistence.storageClass=cstor-sc

👁 Image

Let’s verify the Pod, PVC, and PV associated with the deployment.

kubectl get pods

👁 Image

kubectl get pvc

👁 Image

kubectl get pv

👁 Image

Creating Test Data

Access the PgSQL client to create a test database, table, and adding a row.

First, let’s retrieve the password from the deployment.

export POSTGRES_PASSWORD=$(kubectl get secret --namespace default demo-postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decode)
kubectl run pgsql-postgresql-client --rm --tty -i --restart='Never' --namespace default --image docker.io/bitnami/postgresql:11.7.0-debian-10-r9 --env="PGPASSWORD=$POSTGRES_PASSWORD" --command -- psql testdb --host demo-postgresql -U postgres -d postgres -p 5432

👁 Image

CREATE DATABASE inventory;
\c inventory
CREATE TABLE products (
 product_no integer,
 name text,
 price numeric
);

INSERT INTO products VALUES (1, ‘Cheese’, 9.99);

SELECT * FROM products;

👁 Image

Simulating a Node Failure

Let’s find the node running the PostgreSQL database Pod and cordon it off which will prevent new Pods from being scheduled on it.

kubectl get pods -o wide

👁 Image

 kubectl cordon ip-192-168-71-85.ap-south-1.compute.internal
kubectl get nodes

👁 Image

Finally, we will delete the Pod running on the cordoned node.

kubectl delete pod demo-postgresql-0

Verifying the Data in the new Pod

As soon as the Pod is deleted, the Kubernetes controller will create a new Pod and schedules it in a different node. It cannot be placed on the same node as the scheduling is disabled after cordoning it.

👁 Image

Even though the PVC has the access mode as ReadWriteOnce which is mounted by a specific node for read-write access, the Pod is able to target the same PVC through the cStor storage pool which abstracted the underlying EBS volumes into a single storage layer.

👁 Image

Now, let’s connect to the new Pod and check if the data is intact.

kubectl run pgsql-postgresql-client --rm --tty -i --restart='Never' --namespace default --image docker.io/bitnami/postgresql:11.7.0-debian-10-r9 --env="PGPASSWORD=$POSTGRES_PASSWORD" --command -- psql testdb --host demo-postgresql -U postgres -d postgres -p 5432
\c inventory
select * from products;

👁 Image

The data is intact even after deleting the Pod and rescheduling it on a different node. This confirms that the replication factor of OpenEBS is working properly.

In the next part of this series, we will see how to take volume snapshots and backup the state of the workload. Stay tuned!

Janakiram MSV’s Webinar series, “Machine Intelligence and Modern Infrastructure (MI2)” offers informative and insightful sessions covering cutting-edge technologies. Sign up for the upcoming MI2 webinar at http://mi2.live.

TRENDING STORIES
Janakiram MSV (Jani) is a practicing architect, research analyst, and advisor to Silicon Valley startups. He focuses on the convergence of modern infrastructure powered by cloud-native technology and machine intelligence driven by generative AI. Before becoming an entrepreneur, he spent...
Read more from Janakiram MSV
SHARE THIS STORY
TRENDING STORIES
TNS owner Insight Partners is an investor in: Class.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.