Hands On: Containerizing Python and Deploying to IoT and Edge Devices
Containerizing Python and Deploying to IoT and Edge Devices
Python developers certainly understand how flexible and versatile python applications can be, and could easily name a dozen (or more) potential use cases for python. But let's focus on one very important and rapidly expanding use case, the Internet of Things. In the world of IoT, python can be used for reading data from sensors, enabling Artificial Intelligence and Machine Learning at the edge, and building smart cities that adapt and interact with humans and objects. Developing all of this locally on your laptop or a small prototype device like a Raspberry Pi or Beaglebone is great, but when it comes to deploying devices out into the world, special considerations need to be taken. This is a great opportunity to make use of Docker containers, so let's explore how to place your Python into a container, and push it onto devices, using the balenaCloud platform.
- We will start off with a simple python application, running locally.
- Next, we will wrap a container around it.
- Then, we will push that container onto a Raspberry Pi attached to balenaCloud, functioning as an IoT device.
- Next, we'll make a change to the application, and deploy the newly updated container to the Pi.
- Finally, we can scale up the number of devices, and talk about lessons learned for devices in remote locations.
Normally this type of content would be delivered in a classroom setting, but since PyCon India is a virtual conference this year, we're going to have to get creative! Not to worry though, I will explain and demonstrate each of the steps above, on camera and with screenshare and some prepared slides, and will help attendees complete each item. You will need a Raspberry Pi if you are going to follow along, preferably a Pi 3 or Pi 4.
Questions and Discussion
We'll do our best to make it an interactive session, and make sure everyone follows along and completes each step. I will present each task, demonstrate it, then assist folks with completing the step, prior to moving on. Of course, we'll also be sure to provide follow up contact info and our community / social channels for anything else!
- Basic knowledge of Docker Containers, just the high level concepts are fine in order to follow along.
- A Raspberry Pi, SD Card, and power supply, in order to follow along and participate.
- If your desktop or laptop PC doesn't have an SD Card, you may need a USB adapter in order to flash the SD Card.
These will be built and shared later, but balena has many existing sample projects and GitHub repo's containing containerized python applications. For example, balenaSense is a nice python-driven environmental monitoring solution for IoT devices: https://github.com/balenalabs/balena-sense
David Tischler, Developer Advocate, balena.io
David Tischler is a Developer Advocate at balena, helping to teach developers how to build containers to run on small IoT devices. David is passionate about tech-for-good, and the use of small form-factor computing to help reduce the environmental impact of infrastructure. David has spoken at:
- Arm TechCon 2018, 2019
- Linaro Connect 2019 (x2)
- AIoT Dev Fest 2020[HTML_REMOVED] ...then came a global pandemic…
- Arm Dev Summit 2020 (upcoming)
You can find him at:
- Linkedin - https://www.linkedin.com/in/david-tischler-msim-2076a25a/
Vipul Gupta, Software Engineer, balena.io
Vipul Gupta is a software engineer at balena. Apart from being a pseudo graduate no thanks to Covid, he advocates strongly for open-source, better documentation and party parrots. In his personal time, he organises meetups for PyDelhi and is a frequent speaker at conferences (and podcasts). He also runs a OSS documentation initiative called Mixster. You can find him all over the web by @vipulgupta2048
- Twitter - https://twitter.com/vipulgupta2048/
- Linkedin - https://www.linkedin.com/in/vipulgupta2048/
- Website - http://vipulgupta2048.me