Nutanix PostgreSQL EDB on Kubernetes: A How-To Guide

A Comprehensive Guide

Introduction: Nutanix Enterprise Database (EDB) is a powerful, enterprise-grade database solution that offers high availability, scalability, and performance. Nutanix EDB supports various database engines, including PostgreSQL. In this article, we will explore how to integrate Nutanix EDB with Kubernetes to deploy and manage PostgreSQL databases.

Prerequisites: Before we begin, ensure you have the following prerequisites in place:

  1. A Nutanix EDB cluster
  2. A Kubernetes cluster
  3. Nutanix Kubernetes Operator installed
  4. Kubectl installed and configured

Step 1: Create a Kubernetes Secret To store the Nutanix EDB credentials, we need to create a Kubernetes secret. Run the following command to create a YAML file named nutanix-credentials.yaml:

apiVersion: v1
kind: Secret
metadata:
  name: nutanix-credentials
type: Opaque
stringData:
  NUTANIX_ACCOUNT: <your_Nutanix_account>
  NUTANIX_PASSWORD: <your_Nutanix_password>
  NUTANIX_CLUSTER_NAME: <your_Nutanix_cluster_name>
  NUTANIX_DATABASE_NAME: <your_Nutanix_database_name>
  NUTANIX_USERNAME: <your_Nutanix_username>
  NUTANIX_PASSWORD_ENC: <encrypted_Nutanix_password>

Replace the placeholders with your actual Nutanix account details and encrypted Nutanix password.

Step 2: Create a PostgreSQL Persistent Volume Create a persistent volume for your PostgreSQL database using the Nutanix Storage Cluster. Run the following command to create a YAML file named postgresql-pvc.yaml:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: postgresql-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  storageClassName: nutanix-storage-class

Replace the storage value with the desired size for your PostgreSQL database.

Step 3: Create a PostgreSQL Deployment Create a Kubernetes deployment for your PostgreSQL database using the Nutanix Operator. Run the following command to create a YAML file named postgresql-deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgresql-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgresql
  template:
    metadata:
      labels:
        app: postgresql
    spec:
      containers:
      - name: postgresql
        image: postgres:latest
        env:
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              name: nutanix-credentials
              key: NUTANIX_PASSWORD
        ports:
        - containerPort: 5432
        volumeMounts:
        - name: postgresql-data
          mountPath: /var/lib/postgresql/data
      volumes:
      - name: postgresql-data
        persistentVolumeClaim:
          claimName: postgresql-pvc

Step 4: Apply the Configurations Apply the YAML files using the kubectl apply -f command:

kubectl apply -f nutanix-credentials.yaml
kubectl apply -f postgresql-pvc.yaml
kubectl apply -f postgresql-deployment.yaml

Conclusion: In this article, we explored how to integrate Nutanix EDB with Kubernetes to deploy and manage a PostgreSQL database. We created a Kubernetes secret to store the Nutanix EDB credentials, a persistent volume for the PostgreSQL database, and a Kubernetes deployment using the Nutanix Operator. With these steps, you can easily manage your PostgreSQL databases in a Kubernetes environment using Nutanix EDB.