Setting up hasura local development
Hasura local development allows you to run the hasura platform locally on your computer. It is PaaS with BaaS componenets.
The official instructions to setup hasura local development:
The above instructions to setup local development are constantly updated with the latest instructions.
Prerequisites
- Atleast 4GB RAM and a 64-bit system
- VirtualBox (It is needed as hasura local development is installed in a VM). VirtualBox is a hypervisor that allows us to run a guest OS within our host OS. In our case we will be running a linux based OS (guest OS) in which ever OS (host OS) you will be installing hasura local development.
- Virtualization support. It can be enabled in the BIOS/UEFI. You can follow this guide.
- Windows users must additionally install git bash. You can follow these instructions.
We can now start the installation of hasura local development.
Hasura offers a command-line tool called hasuractl which is used for installing local development.
You can install it by running this command:
- Linux :
curl -Lo hasuractl https://storage.googleapis.com/hasuractl/v0.1.2/linux-amd64/hasuractl && chmod +x hasuractl && sudo mv hasuractl /usr/local/bin/
- macOS :
curl -Lo hasuractl https://storage.googleapis.com/hasuractl/v0.1.2/darwin-amd64/hasuractl && chmod +x hasuractl && sudo mv hasuractl /usr/local/bin/
- Windows : Download
hasuractl.exe
and add it to your PATH
We need to install kubectl, a command-line tool for managing the kubernetes cluster.
- Linux :
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x ./kubectl && sudo mv ./kubectl /usr/local/bin/kubectl
- macOS :
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x ./kubectl && sudo mv ./kubectl /usr/local/bin/kubectl
- Windows : Download
kubectl.exe
and add it to your PATH
Create an account on beta.hasura.io if you haven’t already.
Run hasuractl login
and enter the username and password when prompted.
Once logged in successfully, proceed to the next step.
Run hasuractl local start
. This will download about 1 to 1.5 GB of docker images.
This step will take some time depending on your internet connection.
Open the specified login URL and login with the given credentials.
If you see the above screen with a green tick on the bottom right, then you have successfully installed hasura local development. You can stop hasura local development once you have completed your work by running hasuractl local stop
.
If you don’t see the green tick, then scroll down to the troubleshooting section.
Exposing local hasura project to the internet
Run hasuractl local expose
to expose your project to the internet. It will be accessible as long as the computer in which you are running hasura local development is connected to the Internet.
Adding ssh-key
Create a public ssh-key by following these instructions, and then run hasuractl project add-ssh-key
.
Common errors and troubleshooting
...The system cannot find the PATH specified.
or... is not recognized as an internal or external command, operable program or batch file.
You haven’t added the program to PATH correctly.
Error starting host: Error creating host: Error executing step: Running precreate checks.: This computer doesn't have VT-X/AMD-V enabled. Enabling it in the BIOS is mandatory
You haven’t enabled virtualization or your system doesn’t support virtualization. Try the instructions given in this post.
Error starting host: Error creating host: Error executing step: Running precreate checks.: We support Virtualbox starting with version 5. Your VirtualBox install is “WARNING: The vboxdrv kernal module is not loaded. …
Ensure that you are running the latest version of VirtualBox. If you are running the latest version and still get the same error then, disable Secure Boot in the BIOS/UEFI and try again. Also run sudo /sbin/rcvboxdrv setup
or equivalent command for your OS
Error starting host: Error creating host: Error executing step:Creating VM.: Error setting up host only network on machine start: The host-only adapter we just created is not visible. …
Disable Secure Boot in BIOS/UEFI and try again
Kube Config Error: open /.kube/config: The system cannot find the path specified.
If you are running this command from Command Prompt in Windows, then run it from git-bash instead.
watch err: EOF
This is not really a error. Wait for some time, hasuractl will automatically handle this error and retry. This generally occurs if the installation is interrupted manually or if the internet connection is not stable.
Error starting host: Error getting state for host: machine does not exist.
Run hasuractl local clean
and then hasuractl local start
. If the same error appears again then delete ~/.minihasura
folder and try again.
- If the pod status is
ImagePullBackOff
orError
for any pod when you runkubectl -n hasura get po
The image will be automatically downloaded again, wait patiently. Ensure that the internet is stable. If the error continues for a very long time, try hasuractl local clean
and then hasuractl local start
.
- When trying to reach the console if you get
504 Gateway Time-out
orThis site can't be reached
or{"message":"No routes defined for this subdomain"}
Wait for some time, it takes some time for all components to start running. Ensure that all the pod statuses are Running
when you run kubectl -n hasura get po
.
'postgress.hasura' is not resolved
Run kubectl delete po -n kube-system -l k8s-app=kube-dns
and try again after a few seconds.