|
| 1 | +.. _manage-applications: |
| 2 | + |
| 3 | +How to manage applications |
| 4 | +========================== |
| 5 | + |
| 6 | +> See also: :ref:`juju:application` |
| 7 | + |
| 8 | +Deploy an application |
| 9 | +--------------------- |
| 10 | + |
| 11 | +To deploy an application, find and deploy a charm / bundle that delivers it. |
| 12 | + |
| 13 | +> See more: :ref:`deploy-a-charm` |
| 14 | + |
| 15 | +View details about an application |
| 16 | +--------------------------------- |
| 17 | + |
| 18 | +To view details about an application on python-libjuju, you may use various `get_*` methods that are defined for applications. |
| 19 | + |
| 20 | +For example, to get the config for an application, call `get_config()` method on an `Application` object: |
| 21 | + |
| 22 | +.. code:: python |
| 23 | +
|
| 24 | + config = await my_app.get_config() |
| 25 | +
|
| 26 | +
|
| 27 | +> See more: `Application.get_config (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.get_config>`_, `Application (methods) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application>`_ |
| 28 | + |
| 29 | + |
| 30 | +Trust an application with a credential |
| 31 | +-------------------------------------- |
| 32 | + |
| 33 | +Some applications may require access to the backing cloud in order to fulfil their purpose (e.g., storage-related tasks). In such cases, the remote credential associated with the current model would need to be shared with the application. When the Juju administrator allows this to occur the application is said to be *trusted*. |
| 34 | + |
| 35 | +To trust an application during deployment in python-libjuju, you may call the `Model.deploy()` with the `trust` parameter: |
| 36 | + |
| 37 | +.. code:: python |
| 38 | +
|
| 39 | + await my_model.deploy(..., trust=True, ...) |
| 40 | +
|
| 41 | +To trust an application after deployment, you may use the `Application.set_trusted()` method: |
| 42 | + |
| 43 | +.. code:: python |
| 44 | +
|
| 45 | + await my_app.set_trusted(True) |
| 46 | +
|
| 47 | +
|
| 48 | +> See more: `Application.set_trusted (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.set_trusted>`_, `Application.get_trusted (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.get_trusted>`_ |
| 49 | + |
| 50 | + |
| 51 | +Run an application action |
| 52 | +------------------------- |
| 53 | + |
| 54 | +> See more: :ref:`manage-actions` |
| 55 | + |
| 56 | +Configure an application |
| 57 | +------------------------ |
| 58 | + |
| 59 | +**Get values.** To view the existing configuration for an application on python-libjuju, you may use the `Application.get_config()` method: |
| 60 | + |
| 61 | +.. code:: python |
| 62 | +
|
| 63 | + config = await my_app.get_config() |
| 64 | +
|
| 65 | +
|
| 66 | +**Set values.** To set configuration values for an application on python-libjuju: |
| 67 | + |
| 68 | +* To configure an application at deployment, simply provide a `config` map during the `Model.deploy()` call: |
| 69 | + |
| 70 | +.. code:: python |
| 71 | +
|
| 72 | + await my_model.deploy(..., config={'redirect-map':'https://demo'}, ...) |
| 73 | +
|
| 74 | +
|
| 75 | +* To configure an application post deployment, you may use the `Application.set_config()` method, similar to passing config in the deploy call above: |
| 76 | + |
| 77 | +.. code:: python |
| 78 | +
|
| 79 | + await my_app.set_config(config={'redirect-map':'https://demo'}) |
| 80 | +
|
| 81 | +
|
| 82 | +> See more: `Application.set_config (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.set_config>`_, `Application.get_config (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.get_config)>`_ |
| 83 | + |
| 84 | + |
| 85 | +.. _scale-an-application: |
| 86 | +Scale an application |
| 87 | +-------------------- |
| 88 | + |
| 89 | +> See also: :ref:`juju:scaling` |
| 90 | + |
| 91 | +Scale an application vertically |
| 92 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 93 | + |
| 94 | +To scale an application vertically, set constraints for the resources that the application's units will be deployed on. |
| 95 | + |
| 96 | +> See more: :ref:`manage-constraints-for-an-application` |
| 97 | + |
| 98 | +Scale an application horizontally |
| 99 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 100 | + |
| 101 | +To scale an application horizontally, control the number of units. |
| 102 | + |
| 103 | +> See more: :ref:`control-the-number-of-units` |
| 104 | + |
| 105 | + |
| 106 | +Make an application highly available |
| 107 | +------------------------------------ |
| 108 | +> See also: :ref:`juju:high-availability` |
| 109 | + |
| 110 | +1. Find out if the charm delivering the application supports high availability natively or not. If the latter, find out what you need to do. This could mean integrating with a load balancing reverse proxy, configuring storage etc. |
| 111 | + |
| 112 | +> See more: `Charmhub <https://charmhub.io/>`_ |
| 113 | + |
| 114 | +2. Scale up horizontally as usual. |
| 115 | + |
| 116 | +> See more: {ref}`How to scale an application horizontally <5476md>` |
| 117 | + |
| 118 | +Every time a unit is added to an application, Juju will spread out that application's units, distributing them evenly as supported by the provider (e.g., across multiple availability zones) to best ensure high availability. So long as a cloud's availability zones don't all fail at once, and the charm and the charm's application are well written (changing leaders, coordinating across units, etc.), you can rest assured that cloud downtime will not affect your application. |
| 119 | + |
| 120 | +> See more: `Charmhub | wordpress <https://charmhub.io/wordpress>`_, `Charmhub | mediawiki <https://charmhub.io/mediawiki>`_, `Charmhub | haproxy <https://charmhub.io/haproxy>`_ |
| 121 | + |
| 122 | +Integrate an application with another application |
| 123 | +------------------------------------------------- |
| 124 | + |
| 125 | +> See more: :ref:`manage-relations` |
| 126 | + |
| 127 | + |
| 128 | +Manage an application’s public availability over the network |
| 129 | +------------------------------------------------------------ |
| 130 | + |
| 131 | +To expose some or all endpoints of an application over a network, you may use the `Application.expose()` method, as follows: |
| 132 | + |
| 133 | +.. code:: python |
| 134 | +
|
| 135 | + await my_app.expose(exposed_endpoints=None) # everything's reachable from 0.0.0.0/0. |
| 136 | +
|
| 137 | +
|
| 138 | +To expose to specific CIDRs or spaces, you may use an `ExposedEndpoint` object to describe that, as follows: |
| 139 | + |
| 140 | +.. code:: python |
| 141 | +
|
| 142 | + # For spaces |
| 143 | + await my_app.expose(exposed_endpoints={"": ExposedEndpoint(to_spaces=["alpha"]) }) |
| 144 | +
|
| 145 | + # For cidrs |
| 146 | + await my_app.expose(exposed_endpoints={"": ExposedEndpoint(to_cidrs=["10.0.0.0/24"])}) |
| 147 | +
|
| 148 | + # You may use both at the same time too |
| 149 | + await my_app.expose(exposed_endpoints={ |
| 150 | + "ubuntu": ExposedEndpoint(to_spaces=["alpha"], to_cidrs=["10.0.0.0/24"]) |
| 151 | + }) |
| 152 | +
|
| 153 | +
|
| 154 | +
|
| 155 | +To unexpose an application, use the `Application.unexpose()` method: |
| 156 | + |
| 157 | +.. code:: python |
| 158 | +
|
| 159 | + await my_app.unexpose() # unexposes the entire application |
| 160 | +
|
| 161 | + await my_app.unexpose(exposed_endpoints=["ubuntu"]) # unexposes the endpoint named "ubuntu" |
| 162 | +
|
| 163 | +
|
| 164 | +> See more: `ExposedEndpoint (methods) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.ExposedEndpoint>`_, `Application.expose() <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.expose>`_, `Application.unexpose() <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.unexpose>`_ |
| 165 | + |
| 166 | + |
| 167 | +.. _manage-constraints-for-an-application: |
| 168 | +Manage constraints for an application |
| 169 | +------------------------------------- |
| 170 | + |
| 171 | +> See also: :ref:`juju:constraint` |
| 172 | + |
| 173 | +**Set values.** To set constraints for application in python-libjuju: |
| 174 | + |
| 175 | +* To set at deployment, simply provide a `constraints` map during the `Model.deploy()` call: |
| 176 | + |
| 177 | +.. code:: python |
| 178 | +
|
| 179 | + await my_model.deploy(..., constraints={'arch': 'amd64', 'mem': 256}, ...) |
| 180 | +
|
| 181 | +
|
| 182 | +* To set constraints post deployment, you may use the `Application.set_contraints()` method, similar to passing constraints in the deploy call above: |
| 183 | + |
| 184 | +.. code:: python |
| 185 | +
|
| 186 | + await my_app.set_constraints(constraints={'arch': 'amd64', 'mem': 256}) |
| 187 | +
|
| 188 | +
|
| 189 | +**Get values.** To see what constraints are set on an application, use the `Application.get_constraints()` method: |
| 190 | + |
| 191 | +.. code:: python |
| 192 | +
|
| 193 | + await my_app.get_constraints() |
| 194 | +
|
| 195 | +
|
| 196 | +> See more: `Application.set_contraints() <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.set_constraints>`_, `Application.get_constraints (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.get_constraints>`_ |
| 197 | + |
| 198 | + |
| 199 | +Change space bindings for an application |
| 200 | +---------------------------------------- |
| 201 | + |
| 202 | +To set bindings for an application on python-libjuju, simply pass the `bind` parameter at the `Model.deploy()` call: |
| 203 | + |
| 204 | +.. code:: python |
| 205 | +
|
| 206 | + await my_model.deploy(..., bind="db=db db-client=db public admin-api=public", ...) |
| 207 | +
|
| 208 | +Python-libjuju currently doesn't support resetting space bindings post deployment, please use the `juju-cli` for that. |
| 209 | + |
| 210 | +> See more: [`Model.deploy()` (method) <5476md>` |
| 211 | + |
| 212 | +Upgrade an application |
| 213 | +---------------------- |
| 214 | + |
| 215 | +To upgrade an application, update its charm. |
| 216 | + |
| 217 | +> See more: :ref:`update-a-charm` |
| 218 | + |
| 219 | +.. _remove-an-application: |
| 220 | + |
| 221 | +Remove an application |
| 222 | +--------------------- |
| 223 | + |
| 224 | +> See also: :ref:`juju:removing-things` |
| 225 | + |
| 226 | +To remove an application from a model in python-libjuju, you have two choices: |
| 227 | + |
| 228 | +(1) If you have a reference to a connected model object (connected to the model you're working on), then you may use the `Model.remove_application()` method: |
| 229 | + |
| 230 | +.. code:: python |
| 231 | +
|
| 232 | + await my_model.remove_application(my_app.name) |
| 233 | +
|
| 234 | +
|
| 235 | +(2) If you have a reference to the application you want to remove, then you may use the `Application.destroy()` directly on the application object you want to remove: |
| 236 | + |
| 237 | +.. code:: python |
| 238 | +
|
| 239 | + await my_app.destroy() |
| 240 | +
|
| 241 | +> See more: `Model.remove_application (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.model.html#juju.model.Model.remove_application>`_, `Application.destroy (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.destroy>`_ |
0 commit comments