Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PyCon 24: Pythonic Deployment - Juju and Charms

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.

This talk was held on May 24, 2024 at PyCon 24, Florence, Italy.

See original slides at https://slides.com/bittner/pycon24-pythonic-deployment-juju-charms

Peter Bittner

May 24, 2024
Tweet

More Decks by Peter Bittner

Other Decks in Programming

Transcript

  1. 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 ore
  2. 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)
  3. DEPLOY YOUR APPLICATION Scripted setup (create virtual environment, copy source

    code to host, use Git, Bash, Ansible, etc.) Python package (pip install) 🤖
  4. 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.) 🤖
  5. 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, Docker le, docker compose) 🤖
  6. 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, Docker le, docker compose) Kubernetes (use Helm or Kustomize, write YAML code, kubectl apply, GitOps, etc.) 🤖
  7. 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, Docker le, 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 😬
  8. DIFFERENT PROBLEMS SOLVED Scripted setup ... bring up same setup

    as locally developed Python package ... install the Python way 💡
  9. DIFFERENT PROBLEMS SOLVED Scripted setup ... bring up same setup

    as locally developed Python package ... install the Python way System package ... combine binaries, con g and data les (deploy following distro conventions) 💡
  10. DIFFERENT PROBLEMS SOLVED Scripted setup ... bring up same setup

    as locally developed Python package ... install the Python way System package ... combine binaries, con g and data les (deploy following distro conventions) Container ... satisfy dependencies independently from target environment 💡
  11. DIFFERENT PROBLEMS SOLVED Scripted setup ... bring up same setup

    as locally developed Python package ... install the Python way System package ... combine binaries, con g and data les (deploy following distro conventions) Container ... satisfy dependencies independently from target environment Kubernetes ... declaratively de ne how containers should work together, let automatic operations do the job 💡
  12. DIFFERENT PROBLEMS SOLVED Scripted setup ... bring up same setup

    as locally developed Python package ... install the Python way System package ... combine binaries, con g and data les (deploy following distro conventions) Container ... satisfy dependencies independently from target environment Kubernetes ... declaratively de ne how containers should work together, let automatic operations do the job 🔦 “ Day-2 activities?
  13. DO EVERYTHING, INCL. OPERATIONS Juju (engine, controller, client) Charms (Python

    code) Rocks (OCI images) Snaps (system packages) optional
  14. juju bootstrap <substrate> <name> juju add-model <name> juju deploy <charmname>

    juju controllers juju models juju status --relations --watch 1s juju K8S CHARM VS. MACHINE CHARM https://juju.is/charms-architecture
  15. JUJU TOOLING & CONCEPTS Juju (engine, controller, client) Charms (Python

    code) Rocks (OCI images) Snaps (system packages) Cloud Controller Model Charm Application Integration Client Action Units https://juju.is/docs/juju/
  16. JUJU TOOLING & CONCEPTS Juju (engine, controller, client) Charms (Python

    code) Rocks (OCI images) Snaps (system packages) charmcraft init pack login upload ... Pebble https://juju.is/docs/sdk/ https://charmhub.io/ https://ubuntu.com/kubernetes/charmed-k8s
  17. JUJU TOOLING & CONCEPTS Juju (engine, controller, client) Charms (Python

    code) Rocks (OCI images) Snaps (system packages) https://canonical-rockcraft.readthedocs-hosted.com/ Alternative way to build container images https://hub.docker.com/u/ubuntu
  18. https://snapcraft.io/ JUJU TOOLING & CONCEPTS Juju (engine, controller, client) Charms

    (Python code) Rocks (OCI images) Snaps (system packages) https://canonical-snapcraft.readthedocs-hosted.com/ self-contained applications no dependency issues simpler deployment
  19. DEMOS charmcraft, rockcraft, snapcraft charm (business & test code) juju

    https://gitlab.com/painless-software/cicd/examples https://gitlab.com/painless-software/docker https://discourse.charmhub.io/t/13912 https://discourse.charmhub.io/t/13389
  20. 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)