Kubernetes and Nutanix NDB Integration
This lab sets up a custom microservices-based application with a VM-based Nutanix Database Service (NDB). It demonstrates integrating NDB-provisioned databases with a vanilla Kubernetes cluster, replacing OpenShift-specific features like Routes with Ingress and Security Context Constraints (SCCs) with Kubernetes security contexts.
NDB provides Database-as-a-Service for Microsoft SQL Server, Oracle, PostgreSQL, MongoDB, and MySQL, enabling efficient management of databases in hybrid multicloud environments. Customers often use VM-based databases due to existing expertise, ease of deployment, and robust high availability, disaster recovery, and security practices.
Lab Duration
Estimated time to complete this lab is 60 minutes.
Fun Fact
The NDB Operator was developed by Nutanix Japan's Solution Engineers (SE) team during a 2022 Hackathon, addressing customer needs for Kubernetes integration. The team won the Hackathon, and the NDB Operator is now available for customers, showcasing Nutanix's commitment to customer value.
Prerequisites
- NDB
v2.5
or later deployed on a Nutanix cluster - Nutanix Kubernetes Platform NKP cluster
v1.15
or later deployed, accessible viakubectl
. See NKP Deployment for NKP install instructions. - Nutanix CSI driver installed for storage integration.
- Networking configured to allow communication between the Kubernetes cluster and NDB.
- NGINX Ingress controller installed for external access.
- Linux Tools VM or equivalent environment with
kubectl
,helm
,curl
, andjq
installed. - NDB server credentials and SSH key pair for database provisioning.
Note
Currently, only Postgres databases are supported by the NDB Operator. Support for other databases (MSSQL, MySQL, Oracle, etc.) will be added incrementally. Check Nutanix release announcements for updates. Nutanix provides 24/7/365 support for Postgres with Postgres Professional. See the solution brief for more details.
High-Level Overview
- Install the NDB Operator on the Kubernetes cluster.
- Deploy a Postgres database using NDB.
- Install a custom three-layer application (React frontend, Django backend, Postgres database).
- Connect the application to the NDB-provisioned database.
- Create database schema and populate data.
- Test the application and verify data in the database.
Install NDB Operator on Kubernetes
Prepare the Linux Tools VM
- Log in to your Linux Tools VM (e.g., via SSH as
ubuntu
). - Create a working directory:
-
Configure
kubectl
to access your NKP Kubernetes cluster: -
Install the latest Cert-Manager as a prerequisite:
-
Verify Cert-Manager is running:
Install the NDB Operator
- Add Nutanix’s Helm repository:
-
Install the NDB Operator
-
Verify the NDB Operator is running:
-
Optionally, view operator logs:
Create NDB Postgres Database
High-Level Steps
- The NDB Operator sends a database creation request to the NDB server.
- The NDB server provisions a Postgres database VM and database.
- The NDB server returns the operation result to the NDB Operator.
Prepare Secrets
-
Create a Kubernetes namespace:
-
Create a Secret for NDB server credentials:
-
Edit
your-ndb-secret.yaml
with your NDB server credentials and apply: -
Create a Secret for the Postgres VM credentials, including an SSH public key:
-
Copy the public key from
~/.ssh/for_ndb.pub
intoyour-secret.yaml
.
Get NDB Cluster UUID
- Set the NDB server IP: Example:
- Retrieve the NDB cluster UUID: Example output: Note the UUID for the next step.
Create NDB Compute Profile
- In the NDB UI, navigate to Profiles > Compute Profile.
- Create a new compute profile:
- Name: DEFAULT_OOB_SMALL_COMPUTE
- CPUs: 4
- Cores per CPU: 2
- Memory: 8GB
Create Postgres Database
- Create an
NDBServer
resource: - Apply the resource:
- Set a database server name:
- Create a
Database
resource:cat << EOF > database.yaml apiVersion: ndb.nutanix.com/v1alpha1 kind: Database metadata: name: dbforflower namespace: ndb spec: ndbRef: ndb isClone: false databaseInstance: clusterId: $NDB_UUID name: "$MY_DB_SERVER_NAME" databaseNames: - predictiondb credentialSecret: your-db-secret size: 10 timezone: "UTC" type: postgres EOF
- Apply the resource:
- Monitor the database provisioning: Example output:
- Check logs for progress:
- Optionally, monitor progress in the NDB UI under Operations. Provisioning takes about ~20 minutes.
Check Database Connectivity
- Verify the database status: Example output:
- Check the Service and Endpoint: Example output:
- Deploy a test Postgres pod:
cat << EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: psql namespace: ndb spec: restartPolicy: Never containers: - name: psql image: postgres:15 command: ["/bin/sh", "-c", "echo 'Pod is running' && sleep 7200"] env: - name: POSTGRES_PASSWORD value: postgres_password securityContext: runAsUser: 1000 runAsGroup: 1000 fsGroup: 1000 EOF
- Connect to the database:
Enter
postgres_password
when prompted. Run: Example output: