![]() |
VOOZH | about |
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.
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.
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.
We will first create a storage class based on the storage pool claim configured in the last tutorial.
kubectl get spc
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
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
Let’s verify the Pod, PVC, and PV associated with the deployment.
kubectl get pods
kubectl get pvc
kubectl get pv
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
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;
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
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
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.
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.
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;
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.