@@ -8,6 +8,10 @@ PostgreSQL and need to deploy it. In a traditional setup, this can be
88quite a challenge, but with Charmcraft you’ll find yourself packaging
99and deploying your Django application in no time.
1010
11+
12+ Introduction
13+ ------------
14+
1115In this tutorial we will build a Kubernetes charm for a Django
1216application using Charmcraft, so we can have a Django application up and
1317running with Juju. Let’s get started!
@@ -24,16 +28,18 @@ This tutorial should take 90 minutes for you to complete.
2428 can be easily deployed, configured, scaled, integrated, etc.,
2529 on any Kubernetes cluster.
2630
31+
2732What you’ll need
28- ----------------
33+ ~~~~~~~~~~~~~~~~
2934
3035- A local system, e.g., a laptop, with amd64 or arm64 architecture
3136 which has sufficient resources to launch a virtual machine with 4
3237 CPUs, 4 GB RAM, and a 50 GB disk.
3338- Familiarity with Linux.
3439
40+
3541What you’ll do
36- --------------
42+ ~~~~~~~~~~~~~~
3743
3844Create a Django application. Use that to create a rock with
3945``rockcraft ``. Use that to create a charm with ``charmcraft ``. Use that
@@ -381,6 +387,7 @@ respond with something similar to
381387 If you are not on the ``amd64 `` platform, the name of the ``.charm ``
382388 file will be different for you.
383389
390+
384391Deploy the Django application
385392-----------------------------
386393
@@ -516,12 +523,22 @@ Now you can open a new tab and visit http://django-hello-world. The
516523Django app should respond in the browser with
517524``The install worked successfully! Congratulations! ``.
518525
519- Add an initial app
520- ------------------
526+
527+ The development cycle
528+ ---------------------
529+
530+ So far, we have worked though the entire cycle, from creating an application to
531+ deploying it. But now -- as in every real-world case -- we will go through the
532+ experience of iterating to develop the application, and deploy each iteration.
533+
534+
535+ Add a "Hello, world" app
536+ ~~~~~~~~~~~~~~~~~~~~~~~~
537+
538+ In this iteration, we'll add a greeting app that returns a ``Hello, world! `` greeting.
521539
522540The generated Django application does not come with an app, which is why
523- we had to initially enable debug mode for testing. Let’s add a greeting
524- app that returns a ``Hello, world! `` greeting. We will need to go back
541+ we had to initially enable debug mode for testing. We will need to go back
525542out to the ``/django-hello-world `` directory where the rock is and enter
526543into the ``/django_hello_world `` directory where the Django application
527544is. Let’s add a new Django app:
@@ -556,6 +573,10 @@ Open the ``django_hello_world/urls.py`` file and edit the imports for
556573 path(" admin/" , admin.site.urls),
557574 ]
558575
576+
577+ Update the rock
578+ ~~~~~~~~~~~~~~~
579+
559580Since we’re changing the application we should update the version of the
560581rock. Go back to the ``/django-hello-world `` directory where the rock is
561582and change the ``version `` in ``rockcraft.yaml `` to ``0.2 ``. The top of
@@ -593,8 +614,13 @@ Now let’s pack and upload the rock using similar commands as before:
593614 :end-before: [docs:repack-update-end]
594615 :dedent: 2
595616
596- Now we can deploy the new version of the Django application from the
597- ``/charm `` directory using:
617+
618+ Redeploy the charm
619+ ~~~~~~~~~~~~~~~~~~
620+
621+ We'll redeploy the new version with ``juju refresh ``.
622+
623+ In the ``/charm `` directory, run:
598624
599625.. literalinclude :: code/django/task.yaml
600626 :language: bash
@@ -618,8 +644,8 @@ inside the Multipass VM. Either way, the Django application should respond
618644with ``Hello, world! ``.
619645
620646
621- Enable a configuration
622- ----------------------
647+ Provide a configuration
648+ -----------------------
623649
624650To demonstrate how to provide a configuration to the Django application,
625651we will make the greeting configurable. We will expect this
@@ -632,6 +658,10 @@ with:
632658.. literalinclude :: code/django/views_greeting_configuration.py
633659 :language: python
634660
661+
662+ Update the rock (again)
663+ ~~~~~~~~~~~~~~~~~~~~~~~
664+
635665Increment the ``version `` in ``rockcraft.yaml `` to ``0.3 `` such that the
636666top of the ``rockcraft.yaml `` file looks similar to the following:
637667
@@ -667,6 +697,10 @@ Let’s pack and upload the rock:
667697 :end-before: [docs:repack-2nd-update-end]
668698 :dedent: 2
669699
700+
701+ Update the charm
702+ ~~~~~~~~~~~~~~~~
703+
670704Change back into the charm directory using ``cd charm ``.
671705
672706The ``django-framework `` Charmcraft extension supports adding
@@ -683,7 +717,8 @@ the end of the ``charmcraft.yaml`` file:
683717 replaced by ``_ ``. A ``DJANGO_ `` prefix will also be added as a
684718 namespace for app configurations.
685719
686- We can now pack and deploy the new version of the Django app:
720+ We can now pack a new version of the charm, and then deploy it once more with ``juju
721+ refresh ``:
687722
688723.. literalinclude :: code/django/task.yaml
689724 :language: bash
0 commit comments