In our previous blog we have seen how to deploy the lagom service on conductr – https://blog.knoldus.com/2017/05/25/deploying-the-lagom-service-on-conductr/
In this blog we will create script to deploy your Lagom service on conduct present or running on top of DCOS.
There are two types of automatic deployments can be done –
- Deploying from scratch (stop the current Lagom bundle and deploy the new one)
- Rolling/Incremental Deployment( Overriding the already running Lagom bundle)
Note* – Currently for automatic deployment on conductr running on DCOS, one need Enterprise Version of DCOS cluster setup rather than the open source. Another way is to disable the authentication.
- Deploying From Scratch –
In this approach one need to stop and unload the running bundle and then need to run the below script.
The Script and its details are as follow –
#!/usr/bin/env bash
if [ -z $1 ]; then
SCALE_FACTOR=1
else
SCALE_FACTOR=$1
fi
rm -rf modules/my-lagom-impl/target/bundle/*.zip
echo “creating bundle………………..”
sbt “project my_lagom_impl” bundle:dist
MY_LAGOM_IMPL_BUNDLE_DIST=modules/my-lagom-impl/target/bundle/my-lagom-impl-1.1-SNAPSHOT-*.zip
echo “Deploying my-lagom-impl…”
MY_LAGOM_IMPL_BUNDLE_ID=$(dcos conduct load $MY_LAGOM_IMPL_BUNDLE_DIST –long-ids -q)
dcos conduct run ${MY_LAGOM_IMPL_BUNDLE_ID} –no-wait -q –scale $SCALE_FACTOR
echo ‘Your system is deployed. Running “conduct info” to observe the cluster.’
dcos conduct info
Explanations –
- SCALE_FACTOR : The Scale factor determines on how many nodes will the Lagom service run.
- rm -rf modules/my-lagom-impl/target/bundle/*.zip : – This commands removes the already present lagom bundle from your target folder.
- bundle:dist : bundle:dist commands actually creates a zip files similarly as JAR file if compared with JAVA of your Lagom Service.
- dcos conduct load $MY_LAGOM_IMPL_BUNDLE_DIST : dcos conduct load command loads your bundle onto the conductR running on DCOS and returns the bundleId in response.
- dcos conduct run ${MY_LAGOM_IMPL_BUNDLE_ID} : – This runs your Lagom Bundle with the help of ID received.
- Rolling/Incremental Deployment
Light Bend conductr cli provides two ways to accomplice this task. One using the Cli itself (newly integrated) and another using the bin tray account. Here we will look into the CLI one.
Step 1)Installing Continuous Delivery service
If only conduct deploy based deployment is desired (i.e. no webhook), simply install and run Continuous Delivery bundle.
conduct load continuous-delivery
conduct run continuous-delivery –scale 2
Step 2)Conduct Deploy Command
The CLI based deployment is done using the conduct deploy
command.
The above script will work untill the step 3 and 4 and instead of using the command DCOS Conduct run/Load we need to use the dcos conduct deploy command.
MY_LAGOM_IMPL_BUNDLE_ID=$(dcos conduct deploy $MY_LAGOM_IMPL_BUNDLE_DIST –long-ids -q)
So that all and the script remains the same.
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.
More details can be found on http://conductr.lightbend.com/docs/2.1.x/ContinuousDeliverySetupOps.
Reblogged this on bigtechnologies.