View on GitHub

MuleSoft_DeploymentAsCode

Mule Deployments as Code

Introduction

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.

Deployment Pipeline

Adopt as part of your DevOps and CI/CD pipeline.

Build and Deployment

The source code repository for environment management is separate from the application source code.

Why Adopt?

The main advantages of the Infrastructure as Code approach allows for:

Why not just deploy from a environment branch from your application source code repository?

How does it work?

Example of deployment descriptor file for CloudHub:

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/'

Framework Logic

How do I get started?

  1. Create source code repository to host your configuration or fork this repository.
  2. Create a branch for the environment. Each environment will require a branch.
  3. Copy of the contents of this repository into your branch if you did not fork this repository.
  4. 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.

  5. Configure the Anypoint platform credentials as environment variables in your CI server:
    • anypoint_username
    • anypoint_password
  6. Update deployment_descriptor.yml with:
    • Env
    • Business Group
    • Applications
    • Applications properties
  7. Commit and push

How do I update application properties?

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

Example:

app_properties/really-cool-api-v1/really-cool-api-dev.properties

Roadmap

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    

Pre-requisites:

Anypoint-cli

Command Line Interface for Anypoint Platform(Anypoint-CLI) is used to:

Nodes.js

Anypoint-CLI is written in Nodes.js hence the framework has been written in Node.js to reduce dependencies.

CI or automation server

Build pipeline

Build pipeline that published build artefacts into a store

Artefacts store/repository

Recommendations:

Contributors