How to manage applications

Deploy an application

To deploy an application, find and deploy a charm that delivers it.

See more: Deploy a charm

Set the machine base for an application

Only for machine clouds.

TBA

Trust an application with a credential

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.

To trust an application with a credential, in the juju_application resource definition, add a trust attribute and set it to true:

resource "juju_application" "this" {
  model = juju_model.development.name

  charm {
    name     = "hello-kubecon"
  }

    trust = true
}

Configure an application

To configure an application, in its resource definition add a configuration map with the key=value pairs you want (from the list of configurations available for the charm).

resource "juju_application" "this" {
  model = juju_model.development.name

  charm {
    name = "hello-kubecon"
  }

  config = {
    redirect-map = "https://demo"      
   }    
}

Scale an application

See also: juju| Scaling

Scale an application vertically

To scale an application vertically, set constraints for the resources that the application’s units will be deployed on.

Scale an application horizontally

To scale an application horizontally, control the number of units.

Make an application highly available

  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.

  1. Scale up horizontally as usual.

Integrate an application with another application

Manage an application’s public availability over the network

Expose. To expose an application over a network, in its resource definition use an expose attribute:

resource "juju_application" "this" {
  model = juju_model.development.name

  charm {
    name = "hello-kubecon"
  }

  expose = {}
}

This will expose all of the application’s endpoints. To restrict exposure to just specific endpoints, spaces, or CIDRs, specify nested attributes.

Unexpose. To unexpose an application, remove the expose attribute from its resource definition.

Manage constraints for an application

To set constraints for an application, in its resource definition specify a constraints attribute followed by a quotes-enclosed, space-separated list of key=value pairs. For example:

resource "juju_application" "this" {
  model = juju_model.development.name

  charm {
    name = "hello-kubecon"
  }

  constraints = "mem=6G cores=2"

}

Change space bindings for an application

See also: juju | Binding

To set space bindings for an application, in its resource definition specify an endpoint_bindings with a space key, to set a default for the entire application, and/or a space and an endpoint key, to set the space binding for a particular application endpoint. For example, below all the application’s endpoints are bound to the public space except for the juju-info endpoint, which will be bound to the private space:

resource "juju_application" "application_three" {
  model = resource.juju_model.testmodel.name
  charm {
    name = "juju-qa-test"
  }
  units = 0
  endpoint_bindings = [
    {
      "space" = "public"
    }
    {
      "space" = "private"
      "endpoint" = "juju-info"
    }
  ]
}

Upgrade an application

To upgrade an application, update its charm.

See more: Update a charm

Remove an application

To remove an application, remove its resource definition from your Terraform plan.

Contributors: @achilleasa , @cderici, @james-garner, @hmlanigan , @nvinuesa , @pedroleaoc , @pmatulis , @stephanpampel , @timClicks , @tmihoc