Skip to Content
APIClustersCreate Cluster

Create cluster

Create an autoscaling cluster: a group of instances behind a load balancer that grows and shrinks with CPU load.

To make an app you are already running highly available, use POST /v1/clusters/from-instance instead. It takes the same fields (minus image, plus instance_id), needs no rebuild or redeploy, and keeps your URL.


Endpoint

POST /v1/clusters

Request body

{ "name": "web-cluster", "image": "IMAGE_ID", "flavor": "m1.small", "min_size": 3, "max_size": 5, "backend_network_id": "NETWORK_ID", "key_name": "KEYPAIR_NAME", "port": 80, "dnsName": "web-cluster-a1b2c3d4.redu.cloud", "scale_out_threshold": 0.7, "scale_in_threshold": 0.2 }

Fields

FieldRequiredDescription
nameyesCluster name
imageyesImage or snapshot every member boots from
flavoryesMember size, e.g. m1.small
min_sizenoMembers always running (default 1). Set 3 for high availability
max_sizenoPeak members under load (default 5). Must be at least min_size
backend_network_idyesPrivate network the members sit on
backend_subnet_idnoDerived from backend_network_id when omitted
key_nameyesSSH keypair name
portnoPort the load balancer routes to (default 80)
dnsNamenoPublic name for the load balancer. Auto-generated when omitted
scale_out_thresholdnoCPU fraction that adds a member (default 0.7)
scale_in_thresholdnoCPU fraction that removes one (default 0.2)

Field sources

FieldWhere to get it
imageList Images
flavorFlavors
backend_network_idList Networks
key_nameSSH Keypairs

High availability

min_size: 3 is the difference between an autoscaling cluster and a highly available one:

  • members are placed on three different physical machines, automatically
  • a destroyed member is rebuilt without you doing anything, in 1.5 to 5 minutes depending on how it failed (both ends measured on the live platform), while the cluster keeps serving on the members that remain
  • updates replace members one at a time, each given time to start serving before the next is taken out

Two members is not highly available. Three is the smallest number that survives losing one.

Members come up one at a time, which is what places them on separate machines, so a 3-member cluster takes longer to build than a single instance. GET /v1/clusters reports progress while it does.

Your image must start the app on every boot (a service definition or a container restart policy, not a first-boot script) and bind its port only once it is ready to serve. A replaced member that boots without the app never joins the load balancer, and nothing reports an error.


Example

curl https://api.redu.cloud/v1/clusters \ -X POST \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "web-cluster", "image": "54f06e50-0459-4699-b0d5-be8df4c220a4", "flavor": "m1.small", "min_size": 3, "max_size": 5, "backend_network_id": "32081aab-e6c7-40d8-bb04-90b0dbb7e8ee", "key_name": "redu-cli-key", "port": 80 }'

Successful response

{ "message": "Stack creation started" }

Creation is asynchronous. Poll GET /v1/clusters until the cluster reports CREATE_COMPLETE.


Notes

  • Cluster creation is asynchronous, and a 201 means the build started, not that it finished
  • Members are built one at a time so they land on separate machines
  • A public name for the load balancer is created for you unless you pass dnsName

Errors

400 Bad Request

401 Unauthorized

403 Forbidden

Last updated on