Once you have declared your deployment target state in a file, the target state can be realised simply by committing the file to a source control system. Mule DaC framework will parse the file (deployment descriptor) and compare with the environment and make the necessary changes. For example, increase the number of workers in CloudHub for an application.
The source code repository for environment management is separate from the application source code.
The main advantages of the Infrastructure as Code approach allows for:
- rollback to previously known state through git revert.
- deployment of multiple applications update together or if you prefer a single application update.
- decouple build from deployment and the promotion of code (binary) through the environments.
- comparison of configuration between environments and know the deployment configuration of your environment any given time.
-
A single binary is promoted through the environments which reduces human error and delay in merging from a feature branch into a environment branch.
-
This framework can be used as part of strategy for Imuntable Server and PhoenixServer which reduces configuration drift
Target state is defined in the deployment descriptor file.
CloudHub:
Env: "DEV"
BusinessGroup: "MuleSoft"
Applications:
-
name: "really-cool-api-v1"
packageName: "really-cool-api-1.0.0-SNAPSHOT.zip"
worker-size: "0.1"
num-of-workers: "2"
runtime: "3.8.5"
region: "eu-west-1"
properties: "really-cool-api-v1-dev.properties"
repo_endpoint: 'https://link-to-your-maven-repository.com/snapshots/'
-
name: "another-really-cool-api-v1"
packageName: "another-really-cool-api-1.0.0-SNAPSHOT.zip"
worker-size: "1"
num-of-workers: "1"
runtime: "3.8.5"
region: "eu-west-1"
properties: "another-really-cool-api-v1-dev.properties"
repo_endpoint: 'https://link-to-your-maven-repository.com/snapshots/'
- If the application is not already deployed then deploy the application.
- Field
name
is used as the unique identifier for the application.
- Field
- If the application is already deployed, then update deployment if there are any changes in:
- Application version
- Field
packageName
is used to compare application version. The application version will be parsed using the maven convention.
- Field
- Worker Configuration
- Worker size
- Number of Workers
- Runtime
- Region
- Application Properties
- CloudHub Properties
- Application version
- Create source code repository to host your configuration or fork this repository.
- Create a branch for the environment. Each environment will require a branch.
- Copy of the contents of this repository into your branch if you did not fork this repository.
- Configure your CI-Server and trigger execution on commit
$ .muleci/deployment.sh deployment_descriptor.yml
Use the same command to trigger deployment from your local development workstation.
- Configure the Anypoint platform credentials as environment variables in your CI server:
- anypoint_username
- anypoint_password
- Update
deployment_descriptor.yml
with:- Env
- Business Group
- Applications
- Applications properties
- Commit and push
Application Properties are maintained based on a folder structure convention. If the property file is empty, no properties will be updated during deployment.
app_properties/[app.name]/[app.name]-[branch].properties
app.name
is thename
field indeployment_descriptor.yml
Example:
app_properties/really-cool-api-v1/really-cool-api-dev.properties
More info on Git Project page
Feature | Deployment Target | Status | Additional details |
---|---|---|---|
Deploy Application | CloudHub | Completed | |
Application properties | CloudHub | Completed | |
Worker Configuration | CloudHub | Completed | runtime version, worker size, num of workers |
CloudHub properties | CloudHub | persistence queue, static ips | |
Default configuration for CircelCI | CircleCI | Completed | |
Create a full example with sample apps | CloudHub | ||
Deploy Applications | Anypoint Runtime Manager | ||
Application properties | Anypoint Runtime Manager |
Command Line Interface for Anypoint Platform(Anypoint-CLI) is used to:
- Get information about deployed applications.
- Update application runtime, e.g. number of Workers.
- Update or deploy application.
Anypoint-CLI is written in Nodes.js hence the framework has been written in Node.js to reduce dependencies.
- Such as Jenkins, Bamboo, CirecleCi, Ansible, Chef, Puppet etc.
Build pipeline that published build artefacts into a store
- Store for application binaries
- Preferably maven repository server, such as Nexus, JFrog, etc.
- Create a branch per environment
- No merging between branches
- Jeyaram Deivachandran
- Igor Repka