Partial deployment is a feature allowing fine control over which parts of the MTA will get processed by the SAP Cloud Deployment service. With this feature you can choose to deploy only certain module(s) and/or resource(s). The SAP Cloud Deployment service then orchestrates the deployment only for the selected parts while ignoring the rest.
Warning
|
All descriptor validations and dependency checks on the processed modules are always executed. If the MTA archive is invalid or, for example, a module has a missing dependency (i.e. service instance which it should be bound to but does not exist), the deployment fails. |
To use this feature, pass one of the following environment variablest to the cf deploy
or cf bg-deploy commands
:
-m <module name> |
Deploy only the module with the specified name. Note: It can be used multiple times. Also this way you will upload all the resources from the descriptor. |
--all-modules |
Deploy all modules. |
-r <resource name> |
Deploy only the resource with the specified name Note:It can be used multiple times. Also this way you will upload all the modules from the descriptor. |
--all-resources |
Deploy all resources.ß |
Only selected modules would be built and included in the MTA archive. This optimizes built & assembly time, the archive size and respectively the upload & processing time in the SAP Cloud Deployment service.
If you only maintain a design time descriptor for your project or module - the mta.yaml
file, it needs to be built before you can deploy it using partial deployment commands. In order to prepare the required artifacts, which include the build results for the modules and the deployment descriptor, or the mtad.yaml
file, you can use the auxiliary commands of the Cloud MTA archive builder.
You can find a few tips about usage of the Cloud MTA Builder commands for the partial build in the "Build only specific MTA modules defined in the mta.yaml
file and deploy them" section below.
If initiated from a mtad.yaml
, the cf deploy
command is capable of assembling an MTA archive just before deployment. The list of modules passed to the (bg-)deploy
command is used to determine which would be included in the assembled archive.
Note
|
For the assembly to work properly, it’s necessary to maintain the path argument in the modules. All selected modules should have this path argument pointing to the appropriate module bits.
|
-
SAP Help Portal: Multitarget Application Commands for the Cloud Foundry Environment
In the current directory, run the command cf deploy -m module-b -r service-2
. This will automatically assemble an MTA archive and deploy it:
$ cf deploy -m module-b -r service-2
Deploying multi-target app archive */mta-examples/hello-world.mtar in org ******** / space ******** as **** ...
Uploading 1 files...
*/mta-examples/hello-world.mtar
OK
...
No deployed MTA detected - this is initial deployment
Processing service "service-2"...
Creating service "service-2" from MTA resource "service-2"...
Creating application "module-b" from MTA module "module-b"...
Uploading application "module-b"...
Scaling application "module-b" to "1" instances...
Staging application "module-b"...
Application "module-b" staged
Starting application "module-b"..
Application "module-b" started and available at "******-*-module-b.cfapps.sap.hana.ondemand.com"
Skipping deletion of services, because the command line option "--delete-services" is not specified.
Process finished.
First run the command mbt assemble
to create the MTAR archive:
$ mbt assemble
INFO assembling the MTA project...
INFO copying the MTA content...
INFO generating the metadata...
INFO generating the MTA archive...
INFO the MTA archive generated at: /Users/i076083/git/mta_examples/partial-build-deploy/mta_archives/hello-world_1.0.0.mtar
INFO cleaning temporary files...
Then deploy the assembled MTAR archive:
$ cf deploy mta_archives/hello-world_1.0.0.mtar -m module-c -r service-3
...
Note
|
This approach is less efficient, as all modules are included in the MTA archive and uploaded to the SAP Cloud Deployment service, while only the selected ones are processed. |
Note
|
Since partial deployment requires all the modules' and resources' dependencies to be resolved, we recommend that you first build and deploy the complete MTA project (using the mbt build command to create the MTA archive (mtar ) file and the cf deploy command to deploy it) and then build and deploy only the changing modules.
|
The command for building specific modules using the Cloud MTA Builder Tool is:
$ mbt module-build -m=<list of modules to build> [options]`
Note
|
We recommend that you always apply the -g option that also generates the deployment descriptor - the mtad.yaml file. The path property for the selected deployable modules in this mtad.yaml will point to the build results of these modules, so you will be able to immediately run the partial deployment command as described in the "Deploy directly from directory via mtad.yaml" section.
|
In the examples below we demonstrate how to use the partial build command in different use cases. These examples are based on the project structure described above and this mta.yaml file.
Build dependencies are defined via the requires
property of the build-parameters
section in the mta.yaml
file. You can find more information here.
In the sample project, module-a
depends on modules module-b
and module-c
.
You can build the module-a
module with all its dependencies using the following command:
$ mbt module-build -m module-a -a -g
The module-b
and module-c
modules will be built before the tool builds the module-a
module.
If you now change the module-b
module and would like to re-build and re-deploy the module-a
module, use the following command:
$ mbt module-build -m module-a,module-b -g
The tool will build the specified modules only in the correct order.
You can find the complete information about the Cloud MTA Build Tools partial build options here.
Once you have your modules built and the mtad.yaml
file generated, you can use the partial deployment command as described in the "Deploy directly from directory via mtad.yaml" section.
Note
|
If you expect to redeploy MTA modules/resources multiple times e.g. when doing minor adjustments to them - it may make sense to do a full deployment once and later only update the modules/resources you want. |