Provisioning

Provision VMs with vagrant & terraform

Pigsty runs on nodes, which are Bare Metals or Virtual Machines. You can prepare them manually, or using terraform & vagrant for provionsing.


Sandbox

Pigsty has a sandbox, which is a 4-node deployment with fixed IP addresses and other identifiers. Check demo.yml for details.

The sandbox consists of 4 nodes with fixed IP addresses: 10.10.10.10, 10.10.10.11, 10.10.10.12, 10.10.10.13.

and a 3-instance PostgreSQL HA cluster: pg-test

There’s a primary singleton PostgreSQL cluster: pg-meta on the meta node, which can be used alone if you don’t care about PostgreSQL high availability.

  • meta 10.10.10.10 pg-meta pg-meta-1

There are 3 additional nodes in the sandbox, with a 3-instance PostgreSQL HA cluster pg-test.

  • node-1 10.10.10.11 pg-test.pg-test-1
  • node-2 10.10.10.12 pg-test.pg-test-2
  • node-3 10.10.10.13 pg-test.pg-test-3

Two optional L2 VIP are bind on primary instances of pg-meta and pg-test:

  • 10.10.10.2 pg-meta
  • 10.10.10.2 pg-test

There’s also a 1-instance etcd cluster, and 1-instance minio cluster on the meta node, too.

pigsty-sandbox

You can run sandbox on local VMs or cloud VMs. Pigsty offers a local sandbox based on Vagrant (pulling up local VMs using Virtualbox), and a cloud sandbox based on Terraform (creating VMs using the cloud vendor API).

  • Local sandbox can be run on your Mac/PC for free. Your Mac/PC should have at least 4C/8G to run the full 4-node sandbox.

  • Cloud sandbox can be easily created and shared. You will have to create a cloud account for that. VMs are created on-demand and can be destroyed with one command, which is also very cheap for a quick glance.


Vagrant

Local sandbox require Vagrant and Virtualbox to work.

Make sure Vagrant and Virtualbox are installed and available on your OS.

MacOS Quick Start

If you are using macOS, You can use homebrew to install both of them with one command (reboot required).

  1. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # Install homebrew
  2. brew install vagrant VirtualBox # Installing Vagrant and Virtualbox on a MacOS host

There are some shortcuts to help you get started quickly: install deps, write static DNS and pull up the 1-node/4-node sandbox.

  1. make deps # Install homebrew, and install vagrant and Virtualbox via homebrew (requires reboot)
  2. make dns # Write static DNS records to local /etc/hosts (requires sudo password)
  3. make meta install # pull up a single meta node and install pigsty on it 1-NODE Sandbox
  4. make full install # pull up 4 nodes and install pigsty on them 4-NODE Sandbox

Vagrant Templates

Pigsty have some Vagrant templates for different scenarios.

TemplatesShortcutSpecComment
meta.rbv14C8G x 1Single Meta Node
full.rbv42C4G + 1C2G x 3Full 4 Node Demo
build.rbvb2C4G x 33-Node EL7,8,9 Building Environment
el7.rbv72C4G + 1C2G x 3EL7 4-nodes Testing Env
el8.rbv82C4G + 1C2G x 3EL8 4-nodes Testing Env
el9.rbv92C4G + 1C2G x 3EL9 4-nodes Testing Env

You can customize the vagrant/Vagrantfile to fit your need:

  1. Specs = [
  2. {"name" => "meta", "ip" => "10.10.10.10", "cpu" => "2", "mem" => "4096", "image" => "generic/centos7" },
  3. {"name" => "node-1", "ip" => "10.10.10.11", "cpu" => "1", "mem" => "2048", "image" => "generic/centos7" },
  4. {"name" => "node-2", "ip" => "10.10.10.12", "cpu" => "1", "mem" => "2048", "image" => "generic/centos7" },
  5. {"name" => "node-3", "ip" => "10.10.10.13", "cpu" => "1", "mem" => "2048", "image" => "generic/centos7" },
  6. ]

And here are some makefile shortcuts to help you manage the VMs:

  1. new: del up # destroy & recreate VMs
  2. clean: del # destroy VMs
  3. up: # pull up all VMs
  4. cd vagrant && vagrant up
  5. dw: # stop all VMs
  6. cd vagrant && vagrant halt
  7. del: # remove all VMs
  8. cd vagrant && vagrant destroy -f
  9. status: # show VM status
  10. cd vagrant && vagrant status
  11. suspend: # pause VMs
  12. cd vagrant && vagrant suspend
  13. resume: # resume VMs
  14. cd vagrant && vagrant resume

Terraform

Terraform is an open-source tool to practice ‘Infra as Code’. Describe the cloud resource you want and create them with one command.

Terraform can be easily installed with homebrew, too: brew install terraform. You will have to create a cloud account to obtain AccessKey and AccessSecret credentials to proceed.

The terraform/ dir have two example templates: one for AWS, and one for Aliyun, you can adjust them to fit your need, or modify them if you are using a different cloud vendor.

Take Aliyun as example:

  1. cd terraform # goto the terraform dir
  2. cp spec/alicloud.tf terraform.tf # use aliyun template

You have to perform terraform init before terraform apply:

  1. terraform init # install terraform provider: aliyun (required only for the first time)
  2. terraform apply # generate execution plans: create VMs, virtual segments/switches/security groups

After running apply and answering yes to the prompt, Terraform will create the VMs and configure the network for you.

The admin node ip address will be printed out at the end of the execution, you can log in and start pigsty installation

Last modified 2023-02-27: add v2.0 images and docs (5b09f12)