Hasura project

A Hasura project is a “git-able” directory in the file system, which captures all the information regarding clusters, microservices and migrations. It can also be used to keep source code for custom microservices that you write.

You can git push hasura master to deploy everything, including your custom microservices, database migrations and project configuration.

Creating a project

$ hasura clone base my-project

# creates a directory called `my-project` and initialize an empty Hasura project
INFO Getting app details...                        app=hasura/base
INFO Found on Hasura hub
INFO Downloading...
INFO Downloaded app to directory
INFO Cloned app successfully

This will ‘clone’ a base project from Hasura Hub. Note, you can clone any project from the hub and use that as a starting point for your new project.

Note

hasura/hello-world is another project that contains a few database migrations, some sample data and even a sample mircoservice to get started quickly.

Note

This command automatically intializes a git repository

Files and directories

The project (a.k.a. project directory) has a particular directory structure and it has to be maintained strictly, else hasura cli would not work as expected. A representative project is shown below:

  • hasura.yaml

This file contains some metadata about the project, namely a name, description and some keywords. Also contains platformVersion which says which Hasura platform version is compatible with this project.

  • clusters.yaml

Info about the clusters added to this project can be found in this file. Each cluster is defined by it’s name allotted by Hasura. While adding the cluster to the project you are prompted to give an alias, which is just hasura by default. The kubeContext mentions the name of kubernetes context used to access the cluster, which is also managed by hasura. The config key denotes the location of cluster’s metadata on the cluster itself. This information is parsed and cluster’s metadata is appended while conf is rendered. data key is for holding custom variables that you can define.

- name: h34-ambitious93-stg
  alias: hasura
  kubeContext: h34-ambitious93-stg
  config:
    configmap: controller-conf
    namespace: hasura
  data: null
  • conf
    • authorized-keys.yaml
      • SSH keys allowed to access the cluster
      • One public key per line
    • *.yaml
      • Configuration for the cluster, split into various yaml files
  • migrations
    • Database migration files are kept in this directory
  • microservices
    • Default directory to store source code for custom microservices
    • Each sub-directory contains source code and Dockerfile

Note

hasura cli doesn’t consider any other files or directories outside of those mentioned above