Hasura Internship Week — 2

2.3 — Setting up Hasura/Local -Development on Windows machine

Anwesh Bohidar
8 min readJun 21, 2017
Hasura.io

Before we begin the setup of Hasura, we have to install the following prerequisites:

  • Oracle virtualbox.
  • git-bash
  • kubectl(latest or -v >= 1.6.0)

Oracle VirtualBox

Oracle VM VirtualBox is free and open source hypervisor(or virtual machine monitor) for x86 systems currently being developed and maintained by Oracle Corporation. It creates and manages guest virtual machines running versions of several operating systems available in the market like Windows, MacOS, Linux, Solaris, Haiku etc. Basically, it creates a separate virtual system within a system running any OS as selected by the user. By default, the virtual machines use the same resources as that of the host machine. However, they can be configured, by some extent, to use isolated resources as well.

In our case VirtualBox plays an essential role. It is a great software to use if you want some other OS in your system but aren’t confident enough to uninstall your current OS. Using it certainly prevents us from running into the complexity and pain of dual booting. It’s biggest advantage is that it is extremely easy to use and its cross-platform support is superb.

Furthermore, VirtualBox is necessary for our local development using Hasura. This makes sense as we would be using containerized applications for our local development(virtual hosting environment).

I recommend going through the following blog to get a deeper insight on virtual machines and usefulness of VirtualBox.

kubectl

kubectl(spelt “cube c. t. l.” and not “cubectel”; don’t want others laughing at you) is a command line interface for running commands against Kubernetes clusters. Kubernetes is an open source system for automating deployment, scaling and management of containerized applications across clusters of hosts. Below you’ll find useful links to learn more about Kubernetes.

Git-bash

Refer to my previous blog to learn about Git-bash.

Hasura Local Installation on Windows

Now, now, hold your horses. Before you jump onto your systems to install the prerequisites, its necessary that your system passes all the bottom-line checks first.

  1. Your windows should be a 64-bit version.
  2. Your system should have at least 4 GB RAM installed(that because your VM will take about 2 GB RAM memory).
  3. A good stable internet connection.(Don’t want to be stuck in the middle with inactivity and frustrating errors while installing.)
  4. Your system should have VT-x/AMD-v enabled: VT-x/AMD-v include a series of extensions for hardware virtualisation in Intel or AMD processor powered systems respectively. In most of the laptops, this setting is turned off, so you have to turn it on in your system BIOS. There’s no set route for accessing this setting as different systems have different BIOS settings. However, in most of the systems, you’ll find it by searching under the security or processor tab of BIOS. Google it if you’re not confident about how to proceed.Here a link that may help you:

Below you’ll find the link to hasura local development repository. It contains all the information about Hasura. I’ll still elucidate the steps here, so don’t worry. Enjoy:

Now, time to get into action. Follow the steps:

1st Step: Install VirtualBox. Download it by clicking on the Windows Host option. The user manuals are included in the downloaded binaries.

2nd Step: Install git-bash(if you haven’t).

3rd Step: Install latest version of kubectl. Download the kubectl.exe for windows from the link provided in the site. Next step is adding it to system PATH. Don’t worry, it’s nothing abstruse. To do this, go to My Computer properties. Select Advanced system settings in the left side of the control panel. This will open a window labeled System properties as shown below:

Now, click on Environment Variables in the lower section of the window. This will open the Environment Variables window as shown. Now double click on the path field in system variables section as highlighted in the pic.

Double click on it. This should open edit environment variable window. Click on New button on top right corner. Now you will be prompted to add/type the path of your system variable. Simply copy the folder path of the kubectl.exe(path of the folder to which kubectl.exe belongs ; in the snapshot given below it is located inside folder F:\kubectl) that you downloaded and paste it in the highlighted section. Press Ok. Done!…Simple.You did great….:)(I hope I don’t need to tell you to press Ok on rest of the windows too…do I?). BTW, you’ll follow the same steps while installing hasura. We’ll see that later.

4th Step: Download hasuractl.exe and place it in your PATH, just like you did while installing kubectl.

Configuring and running Hasura

Done with the installation of hasuractl….Great!!! But hold on, it’s too early for you to celebrate. Because now comes the most tricky and tedious part of our setup.

Before we begin, create an account in hasura.io. Remember your user-id and password as you will be required to login from the console(Your browser won’t help you in this case) before configuring and running hasura.

Now, open git bash by right mouse click and selecting git-bash.

Run hasuractl login

Enter your correct credentials of your account that you created in beta.hasura.io . Oh, make sure you don’t press tab while typing, this will make your input invalid and you would have to run hasuractl login again.

Take a deep breath, and get ready for the next most important part.

Be double sure about internet connection. It should be stable. You don’t want any complications, and believe me there will be.

Run hasuractl local start .

Since you will be running this command for the first time, it will first download minkube(approx. 89MB) and create a virtual machine and lots of stuff, you will see. There will be time when you may think nothing happening, and the application has stopped giving logs. Fret not, its working but, conspicuously. On its first time running, it downloads about 1–1.5 GB docker images, hence the delay. Depending on your internet speed, it may take a very long time. At the end the set-up, you will get a domain, user-id, and password. Refer to the following video. Additionally you can also refer to the git-repository for more details.

At the end of the setup, you will get a url and your login credentials you can use to access hasura console.

To stop hasura, run hasuractl local stop .

Done…Phew.. Now each time you want to run hasura, run above two commands i.e hasuctl local start and hasuractl local stop , of course, after logging in through your command line. Don’t worry, it won’t take any long than a few minutes to setup hasura afterwards. All the hectic works have been dealt with. Your console will kind of look like this:

Interestingly, you can also view your kubenetes pods. Open a separate git-bash after running hasuractl local start and in the new window run the command kubectl get pods -n hasura.

Furthermore, while not running hasura, the command hasuractl local clean will clean your existing hasura platform so that you can start afresh.

The command hasuractl local delete deletes the VM and the entire docker images with it.

To know about its more features, refer to documentation.

Now, you must be wondering what’s so difficult about this stuff. That’s because you don’t know that there’s always a great probability that the application will return an error. There would be no way to fix it. In case you got the whole thing down smoothly, then great…You’re a lucky person. Sadly, I wasn’t. I had to toil with it for almost 28 combined hours, thanks to my shitty internet.

Hasura is still new and under development. It’s not perfect. But all the hard work is woth it as you will know how fast you will be able to develop and deploy your webapp. The backend tasks are all handled by hasura, so you don’t have to work hard as much as you expect. Besides,I’m sure the developers are working hard to make it smooth.

Anyways, should you come across any error while setting up hasura, just run hasuractl local clean followed by hasuractl local delete. Then again hauractl local start so that it creates a new VM and downloads fresh docker images from the beginning. Also, give some time to each of these commands above as some background processes still go on even after the logs have been printed on bash. Every time, you come across any error, follow the above procedure. You should refer to the hasura documentation beforehand to deal with them.

Keep an eye on your network activity through task manger. If its inactive while setting up and the bash doesn’t give logs for a very long time, then press ctrl + C on your keyboard to terminate the command and then follow the above mentioned procedure to start afresh.

The same step has to be followed if come across an error which kind puts the CLI in infinite loop of EOF errors like shown in the pic below. This problem is quite common in Windows.

I hope this blog helps you with installing hasura. Best of luck.

Its over, there’s nothing else to see. No use in scrolling down.

--

--