Automate NC2 Cluster Deployments with Python
Automate NC2 Cluster Deployments with Python
Overview
Deploying Nutanix Cloud Clusters (NC2) can be a complex process, especially when you need to do it quickly for testing, disaster recovery (DR), or ransomware recovery scenarios. To make this process faster and more reliable, I’ve recently published a Python script that automates the deployment of NC2 clusters in an existing AWS VPC. This tool is ideal for anyone who needs repeatable, proven deployments—whether for lab work, DR drills, or rapid recovery.
Why automate NC2 deployments with Python?
- Speed: Go from zero to a running NC2 cluster quickly and with minimal effort
- Repeatability: Use the same script and configuration to deploy identical environments every time.
- Reliability: Proven, version-controlled automation reduces human error and ensures best practices are followed.
- DR & Recovery: Perfect for disaster recovery or ransomware scenarios where you need to bring up a new cluster quickly and consistently.
- Testing: Great for lab environments or proof-of-concept work where you need to spin up and tear down clusters frequently.
Why have a Python as a pet?
Who knows? My pet Python likes to hide in the air conditioner. It takes ages to coax him out of there. At least he gives good hugs.
Features
- Deploys a full NC2 cluster in an existing AWS VPC
- Deploys Prism Central and Flow Virtual Network (FVN) after the cluster is formed
- Uses a simple
.env
file for configuration—easy to update and reuse - Validates your configuration and guides you through the deployment process
- Interactive prompts for cloud account selection and confirmation
- Displays the deployment payload for review before execution
How to use the script
-
Clone the repository:
1 2
git clone https://github.com/jonas-werner/nc2-cluster-deployer.git cd nc2-cluster-deployer
- Set up your environment:
- Create a Python virtual environment and activate it:
1 2
python3 -m venv venv source venv/bin/activate
- Install dependencies:
1
pip install -r requirements.txt
- Create a Python virtual environment and activate it:
- Configure your deployment:
- Copy
sample-dot-env-file
to.env
and fill in your Nutanix API, AWS, and cluster details.
- Copy
- Run the script:
1
python ./create_nc2_cluster_in_existing_aws_vpc.py
- The script will validate your settings, prompt for cloud account selection, and ask for confirmation before deploying.
- Monitor progress:
- The script will provide a cluster ID if it was successful in kicking off the deployment process. You can monitor the deployment in the Nutanix console.
Example use cases
- Disaster Recovery: Quickly spin up a new NC2 cluster in a clean AWS VPC after a failure or ransomware event.
- Testing: Automate cluster creation for lab, QA, or development environments.
- Repeatable Deployments: Use the same script and config to ensure every deployment is consistent and reliable.
Links
- GitHub: NC2 Cluster Deployer Python Script
- Nutanix Cloud Clusters documentation
- Nutanix Developer Portal
Conclusion
This has been a quick intro for how to deploy NC2 clusters using the Nutanix API via a Python script. Hopefully it was useful!
This post is licensed under
CC BY 4.0
by the author.