Project structure: clusters.yaml

clusters.yaml is a file containing the configuration of your infrastructure. It is located at the top-level of a Hasura project directory.

The idea is to have a declarative configuration of your infrastructure so that you can create instances of your infra on-demand.

As this configuration is in a file, it can be version controlled. Hence all is required to create, replicate or move your app (Hasura project) in a new instance is to create a cluster according to this config and push your project to the cluster.

Structure

The clusters.yaml file is a YAML file containing information about your clusters.

It contains the alias as well as the infra spec for the cluster.

The following fields make up the infra spec:

  • version : A Version string.
  • provider : Provider name.
  • region : Region of the cluster
  • nodes : A list of Node of the cluster.
  • volumes : A list of Volume of the cluster.
version: v1
provider: digital-ocean
region: blr1
nodes:
- type: s-2vcpu-4gb
  labels:
    app: postgres
volumes:
- name: postgres
  size: 10
- name: filestore
  size: 30
- name: sessionstore
  size: 5
# custom volume
- name: my-volume
  size: 10

Version

Version of the spec. This is an internal key. It is currently v1.

String

Provider

Name of the provider. Currently only digital-ocean is supported.

String

Region

The slug (string value) of the region name of the provider.

Currently, slug of any valid Digital Ocean region. See this link for all valid regions https://developers.digitalocean.com/documentation/v2/#list-all-regions

String

Node

An object containing the type of node/machine and its labels.

{
    "type" : NodeType,
    "labels": Label

}

Volume

An object containing the name of the volume and its size in GB.

{
    "name" : String,
    "size" : DiskSize
}

NodeType

The type of node (or machine) to be used. Basically, this type represents the CPU, memory (optionally disk size) of the VM or node. The value of this field is provider specific.

For Digital Ocean, the value of this field is any valid slug in this list: https://developers.digitalocean.com/documentation/v2/#list-all-sizes

Label

An object of key value pairs. You can use labels to tag your nodes.

These labels can also be used in your Kubernetes manifests as node selectors.

{
    String : String,
    String : String,
    ..
}

DiskSize

An integer value in GigaBytes (GB). This value cannot be zero.

String

Any string value.

You can list all your clusters using hasura cluster list and add any of them to the project using hasura cluster add.

If you need to remove a cluster from a project, just remove the entry from clusters.yaml.