§Sandbox bundle development

Using the conduct deploy command, it is possible to use the ConductR Sandbox to quickly apply and test configuration tweaks during the development lifecycle of your bundle.

This can be illustrated with the following two examples.

§Example 1: applying configuration tweaks

Let’s assume we have a project that provides a web frontend. The project has sbt-conductr plugin enabled, and the project has the following configuration:

web-frontend {
  notification {
    enabled = false
    enabled = ${?WEB_FRONTEND_NOTIFICATION_ENABLED}

    text = ""
    text = ${?WEB_FRONTEND_NOTIFICATION_TEXT}
  }
}

The web-frontend.notification.enabled and web-frontend.notification.text will be set to false and "" by default. We can override these values by supplying the environment variable WEB_FRONTEND_NOTIFICATION_ENABLED and WEB_FRONTEND_NOTIFICATION_TEXT when the application starts.

The bundle file of the application can be generated by calling the following command.

sbt bundle:dist

We can then use the following command to deploy the generated bundle file into a running ConductR - we’ll assume the Sandbox in this case.

conduct deploy <path to bundle file>

The web frontend project at this point will not have the notification text enabled.

We can redeploy the bundle while supplying the environment variables required to display the notification text as such.

conduct deploy <path to bundle file> \
  --env "WEB_FRONTEND_NOTIFICATION_ENABLED=true" \
  --env "WEB_FRONTEND_NOTIFICATION_TEXT=Easter Sale now on - 30% off all items"

The bundle with notificaton text enabled will be deployed and scaled to replace the original bundle.

Suppose we’d like to change the notification text.

conduct deploy <path to bundle file> \
  --env "WEB_FRONTEND_NOTIFICATION_ENABLED=true" \
  --env "WEB_FRONTEND_NOTIFICATION_TEXT=Easter Sale: 30% off"

The bundle with the new notificaton text will be deployed and scaled to replace the previous bundle. If you wish, you can repeat this process until you are happy with the notification text of your choice.

Suppose now you are happy with the notification text, we can provide the final configuration the operations as such.

bndl --format configuration \
     --env "WEB_FRONTEND_NOTIFICATION_ENABLED=true" \
     --env "WEB_FRONTEND_NOTIFICATION_TEXT=Easter Sale: 30% off" \
     -o easter-sale-config.zip

The easter-sale-config.zip generated by the command above can be given to the operations to be deployed to production.

If you wish to revert to the original bundle without notification text, simply run the following command.

conduct deploy <path to bundle file>

§Example 2: enable debug logs on sandbox

Another common use case is wanting to enable the debug logging in the sandbox.

Let’s assume we have an Akka-based project with sbt-conductr plugin enabled, and the project has the following configuration:

akka.actor.loglevel = info
akka.actor.loglevel = ${?AKKA_LOG_LEVEL}

The akka.actor.loglevel will be set to info by default. If the environment variable AKKA_LOG_LEVEL exists when the application starts, the environment variable will be used instead.

The bundle file of the application can be generated by calling the following command.

sbt bundle:dist

We can then use the following command to deploy the generated bundle file into a running ConductR - we’ll assume the Sandbox in this case.

conduct deploy <path to bundle file>

To enable the debug log level, execute the following command.

conduct deploy <path to bundle file> --env "AKKA_LOG_LEVEL=debug"

The bundle with debug config will be deployed and scaled to replace the original bundle. Once the bundle is running, conduct logs should reveal debug log statements coming from your application.

To revert to the original bundle, simply run the following command.

conduct deploy <path to bundle file>

§Notes on conduct deploy command

The conduct deploy command accepts bundle and optional configuration as its input. The treatment of the bundle and optional configuration input is the same as the conduct load command.

As such, the following are considered as a valid input for both bundle and the optional configuration:

  • Shorthand expression,
  • Actual path to the bundle or configuration .zip file,
  • Directory of the bundle or configuration,
  • Or, the HTTP URL where bundle or configuration .zip file is hosted.

The bundle and optional configuration input to the conduct deploy command will will be processed through the bndl tool where appropriate. This allows operator to provide further configuration on top of the existing input. For example:

conduct deploy visualizer --nr-of-cpus 2.0 --roles web --roles us-east-1 --env "FOO=BAR"

In the example above, the following additional configurations will be applied on the visualizer bundle:

  • Number of CPUs is increased to 2.0.
  • Roles are set to web and us-east-1.
  • Additional environment variable FOO=BAR will be made available to the bundle process when it starts.

To see the available configuration option, run conduct deploy --help.

Next: Resolving other services