Openbalena, is an open-source project by Balena for folks to mange their IOT devices with ease. It’s also the same building blocks that is used to create balena’s own device deployment and management platform which is BalenaCloud.
So, if you want to deploy your infrastructure to manage your IoT fleet, you can go with OpenBalena otherwise you can deploy your IoT devices over on BalenaCloud and live the good life where you won’t have to worry about provisioning, updating, management, maintenance or upkeep of your devices in the field (along with hundreds of other factors of friction that come in IoT deployments that have already been resolved by Balena).
Let’s get right down to it.
The absolute guide to deploying OpenBalena over a VPS (Virtual Private Server) is here. I will be adding on little details to the getting started guide step by step to help you deploy it over Virtualbox the RIGHT way.
Going step by step.
0. Step 0 is preperation. Download and install Virtualbox into your system and run it with the Ubuntu Server image (You can run it with the latest – Mine was Ubuntu Server 20.04 LTS).
My setup is a Xubuntu 18.04 (Host OS) and the guest operating system running in the VirtualBox is Ubuntu Server 20.04 LTS. Get 2 CPU core, 2 gigs of ram, 30 gigs of VDI space. Boot it up and run through the Ubuntu Server setup. Make sure to install the OpenSSH client and authenticate that with your GitHub SSH keys when prompted. We won’t need to install anything else. Also, put the username as
balena only. It helps in the long run. I didn’t explain all the details and abstracted over them. If you didn’t understand, please reach out to me down in the comment section.
- By now, you got a Virtual Machine setup up running Ubuntu Server 20.04 LTS with a
balenauser. You can confirm your specs with mine in the screenshot above. Since you are already in your machine you don’t have to SSH into it.
- All the commands till you run the quickstart script will just go fine. Follow along.
- Run the quickstart script with
sudoto be sure. Next, I went the way of configuring a domain. Which I feel is way simpler. Make sure you are adding the right domain as well as the right credentials. We will need it later.
- Make sure docker is running, if not start the docker instance with the command
sudo systemctl start docker
- Start the instance with the compose script as mentioned. You can monitor the logs of each container using
Configuring the domains
Domain configuration can be done in many ways. Here’s how I did it.
- Shutdown your virtualbox instance and head to the settings panel > Network panel
- Switch your Network Adapter 1’s connection type from the default NAT to Bridged adapter.
- With a bridged adapter, we are trying to make our router assign a unique IP to the virtual machine that we have running.
- Run your machine again, and run the
ifconfigcommand. Pretty sure you won’t have it installed, so install it and then run the command. The IP address should be other than
10.0.2.15, note that IP address.
Let’s come over the domain configuration.
The domain I chose was
Hence, in my domain provider’s dashboard. I setup the DNS to look something like this.
One A record, with ob.vipulgupta2048.me pointing to the IP address of my Virtual Machine.
4 CNAME records for
api.mydomain.com registry.mydomain.com vpn.mydomain.com s3.mydomain.com pointed towards
And that’s about it. When you are done, give it about 10-15 minutes for the DNS records to prograte around the nameservers. You can check that by http://whatsmydns.net/
When it’s done and you see the right IP address coming up, run a command to confirm if your router is able to resolve the right address by running the command.
➜ ~ dig +short <domain name that you have set>
If the IP is right, then your domain name is being resolved correctly and is point to the right place.
Installing the CLI and the Certificate
After installing the CLI in your host or local computer, do make the
.balenarc.yml file. It’s a important step, without it you will be pining the balenaCloud endpoint that are there by default.
To copy the certificate from your virtual machine, you have several ways to go forward.
In a VPS, you can either easily use SCP or SSH into the machine and copy the file back to your own. You can SSH into your virtual machine still, but we can also use the Shared folder’s feature in Virtualbox.
Follow these steps to get it working if it doesn’t work out for you.
When you are done copying the certificates, install them with the command
sudo update-ca-certificates --fresh and then don’t forget to restart your docker instance.
Another reason is to tell Node and balena CLI in your local computer where the certificate is presently located. Since they don’t have root access, giving them the local of the certificate in /usr/local/share/ca-certificates will result in an error of
CERTS_OUT_OF_CHAIN, it can be resolved by giving the right location of the cert file that you have downloaded in your home location. Give it some good read permissions as well if there aren’t there in the first place.
Good, let’s Login.
If you can log in, congratulations you are through. Follow the steps to the end, and I am sure you won’t have any problems. Balena locks this part down pretty well. Provisioning hardware to deployment is a breeze with balena, to be honest.
If you aren’t able to log in, try searching for your error on Google. Almost all of the problems I had were through my own mistakes of not following the getting started guide properly. Implement the solutions as noted on the forums, recheck your steps. If nothing works, and you feel you have a small query. Hit me down in the comment section. I will help you out if I can. Otherwise feel free to open up a new forum post.
If you feel there is any section of the post, that I have not explained properly let me know for that as well. I don’t usually write posts like these but for an experienced user this contains some mighty essential details that will make deploying Openbalena easier.
Well, that’s it folks. Live in the mix!