Sample code using Terraform to deploy an overlay backed segment and configure the NSX-T logical load balancer for CockroachDB.
Terraform project to set up NSX-T Load Balancing for CockroachDB.
This configured the linux system used to invoke Terraform and create the environment.
sudo yum -y install git wget unzip
# Create binary folder mkdir ${HOME}/bin # Download the latest stable terraform package wget `curl -sL https://releases.hashicorp.com/terraform/index.json | jq -r '.versions[].builds[].url' | egrep 'terraform_[0-9]\.[0-9]{1,2}\.[0-9]{1,2}_linux.*amd64' | sort -V | tail -1` -O /tmp/terraform.zip # Extract ${HOME}/bin && unzip /tmp/terraform.zip # Remove zip file rm -f /tmp/terraform.zip # Add to path if [[ -z $(grep 'export PATH=${HOME}/bin:${PATH}' ~/.bashrc) ]]; then echo 'export PATH=${HOME}/bin:${PATH}' >> ~/.bashrc source ~/.bashrc fi # Print version echo "Installed: `${HOME}/bin/terraform version`"
# Change to home directory cd ~ # Clone git repository git clone https://github.com/cleeistaken/automation-cockroach-nsxt-lb.git
As of version 3.1.1 the Terraform NSX-T provider can import a monitor but lacks the functionality to create. The active HTTP monitor will need to be manually created.
Create a NSX-T HTTP monitor.
Ref.
# Change to Terraform folder cd ~/automation-cockroach-nsxt-lb/cockroach/terraform/ # Initialize terraform init # Create a variables file cp terraform.tfvars.sample terraform .tfvars
Edit terraform.tfvars and update the following mandatory fields.
NSX-T Manager
Environment
terraform apply
Network diagram with the CocroachDB nodes deployed.