2.3 Setting up Hasura/local development

Shilpa Jain
6 min readJun 17, 2017

--

Our next task is to setup Local development environment to build our project.

Step by step instructions as provided by Hasura:

Ways in which we can develop and deploy mobile app using hasura:

  1. Have our own infrastructure which means convert our own server computer/laptop into hasura server and deploy on it.It requires 64 bit system.
  2. Subscribe to a certain service provider like Microsoft azure Digital ocean or google cloud and get hasura deployed on it.

Since I have 64 bit Windows system I followed first option .

Before you Start:

  1. Install VirtualBox

[System Requirements : RAM 4Gb Atleast,OS 64 bit (Windows/MacOs /Linux]

Use: We can run different Operating Systems and their versions inside VirtualBox on our system. We basically use it to run minikube on it.

2. Being a Windows user, I had to install git bash.

Use: For executing all the commands. Less prone to errors. It is better than Command Line and is thus recommended.

3. Download hasuractl.exe and place it in your PATH. Refer to this video reference if you need help with the installation on Windows.

Use: With this, minikube gets installed which would run Kubernetes cluster inside the Virtualbox.

4. Install latest kubectl (>= 1.6.0) (https://kubernetes.io/docs/tasks/kubectl/install/)

Use: Manages our containeriszed application.

Note:

Use only git bash to execute your commands.

Use git bash and virtual box in Administrator mode only.

Next, follow these steps:

Starting hasura

  1. Create an account on beta.hasura.io if you do not have one.
  2. Run:

hasuractl login

3. After you have successfully logged in, run this command:

hasuractl local start

Assign the permissions needed(if prompted) and then wait as the work progresses.

NOTE:

Please be advised that if you are running the next command for the first time, it will roughly download about 1–1.5GB of docker images.

It might take a long time for this to finish, depending on your internet connection.

The command exits by pointing you to a url to login to the console.

Using the sign in credentials, log in to the given URL.

Kudos to your patience if you finally see this screen with a green tick mark.

Stopping hasura

hasuractl local stop

This will stop the running hasura platform. You can start it again by running hasuractl local start.

Cleaning hasura

If you like to clean the existing hasura platform to start afresh, you can run this:

hasuractl local clean

NOTE: The above command will delete all data and configuration. However, the underlying VM is not deleted and hence the downloaded images still exist inside the VM. This is what you should be using if you plan to run hasuractl local startagain. If you would also like to delete the underlying VM, you should run this:

hasuractl local delete

The above command will delete the the VM completely and hence all the downloaded images with it.

Errors

  1. First Best possible solution for every issue is to run following commands in sequence:

hasuractl local clean

hasuractl local stop

hasuractl local start

or

hasuractl local stop

hasuractl local delete

hasuractl local start

2. ...The system cannot find the PATH specified.

You’ve not added hasuractl to the PATH correctly and/or you're not using git-bash.

3. If it points that VT and AMD-V virtualization is disabled,

the go to BIOS of your system and Enable it.

4. If you see something like this, then you just need to keep calm and wait.

5. Every “Command not found” is either due to faulty setting of path or bad typing miskates.

6. If on going to the URL you get

Then check the status of your pods by

kubectl get pods -n hasura — show-all

If on executing the above command, you get errors in some pods, then

delete .minihasura,.minikube,.kube,.hasura folders. Cross check VM to ensure deletion. And the repeat the process:

hasuractl login

hausractl local start

7. If on going to the URL, you get

then restart the process by

hasuractl local clean

hasuractl local stop

hasuractl local start

After you receive the log in credentials, wait for some time and they try sigining in again.

8. In case of any infinite loop in your terminal or Gateway error, you need to clean and start again and then wait and retry.

9. When you try to login to the console, if it fails with a message saying ‘postgres.hasura’ is not resolved, run this command:

  • kubectl delete po -n kube-system -l k8s-app=kube-dns

Wait for a few seconds and try again.

10. Virtualbox or minikube errors:

If you are facing errors of the type: Error getting state for host: machine does not exist, try each of the following:

> Run hasuractl local stop and after a few minutes (check your virtualbox console to see if the VM has actually stopped), run hasuractl local start again and everything should be back up.

> If that doesn’t work, run hasuractl local clean, wait for a few minutes and then hasuractl local start again.

> If none of the above work, remove the ~/.minihasura folder and start everything from the beginning of this guide again viz. hasuractl login, hasuractl local start.

Finally you have conquered it. Cheers

More about VirtualBox

VirtualBox is an open source and free software tool that lets you run any Operating System without installing it.

Uses of VitualBox

Users of VirtualBox can load multiple guest OSs under a single host operating-system (host OS). Each guest can be started, paused and stopped independently within its own virtual machine (VM). The user can independently configure each VM and run it under a choice of software-based virtualization or hardware assisted virtualization if the underlying host hardware supports this. The host OS and guest OSs and applications can communicate with each other through a number of mechanisms including a common clipboard and a virtualized network facility. Guest VMs can also directly communicate with each other if configured to do so

In our set up, we have used VirtualBox to run minikube and Kubernetes cluster.

All done! You are ready to go!

We will now proceed to, modelling our apps.

--

--