Pythonic Deployment of (Python) Applications

Juju magic and Charmed operators.

la pizza

la vita

la famiglia

la sorella

la ragazza

la donna

la settimana

la pioggia

la stella

la rosa

la faccia

la scuola

il gatto

il cielo

il cavallo

il giorno

il fratello

il ragazzo

l'uomo

il libro

il tempo

l'anno

la mano (sg.)
  le mani (pl.)  🤔

la sdraio (sg.)
  le sdraio (pl.)  🤯

il padre

il mese

il mare

il fiore

Developer
of people, companies and code

@bittner

@peterbittner, django@bittner.it

Peter Bittner

Orchestration engine

for software operators

deploy & perform day-2 ops

on any cloud or VM or bare metal

operations code in Python modules

(charms, ops framework)

Deploy Your Application

?

Deploy Your Application

  • Scripted setup (create virtual environment, copy source code to host, use Git, Bash, Ansible, etc.)

🤖

Deploy Your Application

  • Scripted setup (create virtual environment, copy source code to host, use Git, Bash, Ansible, etc.)
  • Python package (pip install)

🤖

Deploy Your Application

  • Scripted setup (create virtual environment, copy source code to host, use Git, Bash, Ansible, etc.)
  • Python package (pip install)
  • System package (create + install DEB, RPM, Flatpak, snap, Windows .exe, etc.)

🤖

Deploy Your Application

  • Scripted setup (create virtual environment, copy source code to host, use Git, Bash, Ansible, etc.)
  • Python package (pip install)
  • System package (create + install DEB, RPM, Flatpak, snap, Windows .exe, etc.)
  • Container (copy and install software in container image, Dockerfile, docker compose)

🤖

Deploy Your Application

  • Scripted setup (create virtual environment, copy source code to host, use Git, Bash, Ansible, etc.)
  • Python package (pip install)
  • System package (create + install DEB, RPM, Flatpak, snap, Windows .exe, etc.)
  • Container (copy and install software in container image, Dockerfile, docker compose)
  • Kubernetes (use Helm or Kustomize, write YAML code, kubectl apply, GitOps, etc.)

🤖

Deploy Your Application

  • Scripted setup (create virtual environment, copy source code to host, use Git, Bash, Ansible, etc.)
  • Python package (pip install)
  • System package (create + install DEB, RPM, Flatpak, snap, Windows .exe, etc.)
  • Container (copy and install software in container image, Dockerfile, docker compose)
  • Kubernetes (use Helm or Kustomize, write YAML code, kubectl apply, GitOps, etc.)

Backup / Restore

Application Monitoring
Error tracking

Upgrades

Integrate with other software

Migrate to new hosting

😬

DIFFERENT PROBLEMS SOLVED

!

🤔

Different Problems Solved

  • Scripted setup ... bring up same setup as locally developed

💡

Different Problems Solved

  • Scripted setup ... bring up same setup as locally developed
  • Python package ... install the Python way

💡

Different Problems Solved

  • Scripted setup ... bring up same setup as locally developed
  • Python package ... install the Python way
  • System package ... combine binaries, config and data files (deploy following distro conventions)

💡

Different Problems Solved

  • Scripted setup ... bring up same setup as locally developed
  • Python package ... install the Python way
  • System package ... combine binaries, config and data files (deploy following distro conventions)
  • Container ... satisfy dependencies independently from target environment

💡

Different Problems Solved

  • Scripted setup ... bring up same setup as locally developed
  • Python package ... install the Python way
  • System package ... combine binaries, config and data files (deploy following distro conventions)
  • Container ... satisfy dependencies independently from target environment
  • Kubernetes ... declaratively define how containers should work together, let automatic operations do the job

💡

Different Problems Solved

  • Scripted setup ... bring up same setup as locally developed
  • Python package ... install the Python way
  • System package ... combine binaries, config and data files (deploy following distro conventions)
  • Container ... satisfy dependencies independently from target environment
  • Kubernetes ... declaratively define how containers should work together, let automatic operations do the job

🔦

Day-2 activities?

Do Everything, incl. Operations

optional

K8s Charm vs. Machine Charm

juju bootstrap <substrate> <name>

juju add-model <name>

juju deploy <charmname>

juju controllers

juju models

juju status --relations --watch 1s

juju

Juju Tooling & Concepts

Cloud

Controller

Model

Charm

Application

Integration

Client

Action

Units

JUJU TOOLING & CONCEPTS

charmcraft

init
pack

login

upload

...

Pebble

JUJU TOOLING & CONCEPTS

Alternative way
to build container images

JUJU TOOLING & CONCEPTS

self-contained applications

no dependency issues

simpler deployment

Demos

  • charmcraft, rockcraft, snapcraft
  • charm (business & test code)
  • juju

Thank you!

for your precious time

Painless Software

Less pain, more fun.

Most images generated online (CC-0)
Most logos from Wikipedia (CC-SA)
Decorative icons are unicode (CC-0)

PyCon 24: Pythonic Deployment - Juju and Charms

By Peter Bittner

PyCon 24: Pythonic Deployment - Juju and Charms

How do you deploy your Python (Web) application? If your setup is container-based you’re likely using Kubernetes. Is it fun? No. It’s complex. It’s a lot of YAML. Maybe it’s okay-ish - if your setup is not too complex -, but it could be better. Less complex, more lightweight. And then again, how does your test suite look like for the deployment process? You don’t have any? Sure, it’s all YAML. Yak! What if you could do everything in Python? What if you could “associate” workloads, e.g. a database, with your application in the cloud, using Python code? What if you could write tests with Pytest to ensure your deployment continues to work? Does that sound too good to be true? Canonical has been developing this technology for years. It is proven and solid, yet still exciting to use! Let’s dive into what could be the best you have seen in the last decade for deploying your Python Web application. Say hello to Python and test-driven deployments, ditch YAML and say yes to stability! See a live demo and take home working code to experiment with your own setup. Presentation slides for "Pythonic deployment of (Python) applications", PyCon 24, Firenze. https://2024.pycon.it/en/event/pythonic-deployment-of-python-applications

  • 228