push2cloud – Deploy complex microservice applications in style

push2cloud logo1 dark squareCloud Platforms allow development teams to bring application to production very fast.
In Cloud Foundry a simple ‘cf push’ can be used to deploy your application and bind it to the required services. This works incredibly well for small applications. But as the trend in Cloud Native Applications is going towards microservice architectures, which easily can grow to a large number of decoupled components, it is hard to keep the overview of all the applications and dependencies. It also can get cumbersome and expensive to maintain the deployment scripts and configuration of the applications and very often deployments will get slow and unreliable.

When dorma+kaba was developing exivo, their new trusted, on-demand access control solution for small enterprises, they where exactly facing these challenges, because they had to run and maintain more than 70 apps and 60 services  on the Swisscom Application Cloud.

For that reason dorma+kaba, ZHAW ICCLab and Swisscom joined forces and initiated the push2cloud project which provides you with an advanced and highly configurable solution to manage complex microservice applications in production. Because we know that many organisations are facing the same deployment challenges and we are confident that such a framework is a benefit for the community we decided to release it in Open-Source.

To get more info check our website: www.push2.cloud
The whole project is also available on: github.com/push2cloud.

How does it work

push2cloud provides three main features to address the challenges of deploying complex microservice applications:

Sophisticated application configuration

Developers declare all the requirements of their application in an Application Manifest. Beside the basic deployment information like name, memory, disk storage and environment variables, it also supports to explicitly declare dependencies on services and other applications. This allows push2cloud, to ensure that these services and applications are available before starting the application and provide the required information to connect to the specified applications and services.

Advanced Release- and Deployment management

Releases are compositions of applications in a specific version. This allows to keep control of all the applications belonging to a system and ensures consistent deployments to different environments. deployment manifests finally contain all the required information to run a release in a target environment. This includes the connection information for the target environment (e.g. in Cloud Foundry controller URL, organization and space) as well as all the service definitions, domain and route configurations. It is also possible to override application configurations for a specific deployment. This setup allows to deploy the same release to multiple environments, just by providing a deployment manifest for each.
Based on these manifests, the push2cloud compiler generates a deployment configuration which represent the desired state of the system. On the other hand push2cloud can also retrieve the information from the platform and create a deployment configuration reflecting the actual state of the system. The difference of these two configurations can be used by push2cloud to extract the minimal required steps to migrate the system to the desired state.

Flexible and extensible workflow framework

Workflows are a collection of actions to migrate a system from actual to desired state in a reproducible fashion. There is no deployment workflow, which is fitting every application. Depending on application type, deployment environment (e.g. clean deploy in testing and blue-green in production) or version update (minor vs. major) the workflow may differ. For this reason push2cloud provides a workflow framework. This makes it easy to reuse or adapt existing workflows or write your own highly specialised one.

The picture below shows the basic process of push2cloud.
First it will get your artefacts (source code, configuration, etc.) from the repository defined in the manifests (i.e. on github.com), then it will run the provided build command (e.g. using standard build tools like npm, gradle, maven, etc.) to prepare the applications for deployment. Finally it will execute the specified workflow to push your applications and migrate the system to the desired state.

process

To fulfill the different use cases within complex application landscapes, push2cloud consists of multiple pluggabarchitecturele components and modules that work together to give maximum customizability to the
user. The overall interaction with the deployment is done via the p2c CLI. The deployment compiler is compiles the Deployment Configuration from the manifests. It provides a plugin interface to add support for additional configuration features. CF-Workflows contains a set of common workflows and workflow utilities. Finally the adapter provides an astract interface and is interacting directly with the cloud platform API. Currently only an adapter for Cloud Foundry is implemented.

Getting started

To get started fast push2cloud provides a demo appliation. As a prerequisite NodeJS and npm need to be installed locally.  Start with cloning the push2cloud repo which includes an example deployer and install the dependencies there with npm install.

# get push2cloud
git clone https://github.com/push2cloud/push2cloud.git 
cd push2cloud /example/deployer
#install dependencies
npm install
#install p2c CLI globally
npm install -g push2cloud-cli

Next the deployment manifest needs to be adapted. In this example it is set to the Swisscom Application Cloud as Cloud Foundry target. For that open the file example deployment.json file: “vi ../manifests/deployment.json” and edit the org & space details:

{
 "name": "push2cloud-example",
 "version": "1.0.0",
 "description": "deployment manifest for push2cloud example", "target": { 
  "type": "cloudfoundry",
  "api": "https://api.lyra-836.appcloud.swisscom.com", 
  "space": "demospace",
  "org": "sandbox", 
  "delay": 500, 
  ...

The workflows are going to use the CloudFoundry credentials from the environment variables. Therefore the username and password has to be exported exactly the same way as for the CloudFoundry-CLI.

export CF_USER=${YOUR_USER}
export CF_PWD=${YOUR_PASSWORD}

Before starting the deployment the compiler has to be run to check out the repositories, create the desired deployment configuration and run the build scripts to prepare the application for packageing. On first execution this command takes some time. As a result it will create the deployment configuration (deploymentConfig.json) in the current directory.

p2c compile -e ../manifests/deployment.json

Finally the example application is ready to be deployed to the given space, by executing the BlueGreen workflow.

p2c exec ./node_modules/push2cloud-cf-workflows/blueGreen.js

As a result two application and one service should be running within the defined space.

# cf a
Gettingappsinorg${ORG}/space${SPACE}as${USER}...
OK

name requested state instances memory disk urls
push2cloud-example-api-1.0.0 started 1/1 512M 512M push2cloud-example-api-${SPACE} 
push2cloud-example-host-2.0.0 started 1/1 512M 1G push2cloud-example-host-${SPACE}

# cf s
Getting services in org$ {ORG}/space ${SPACE} as ${USER} ...
OK

name service plan bound apps last operation
todo-db redis small push2cloud-example-api-1.0.0 create succeeded

 If you want to learn more on how to update parts of this applications check out the demo video.
Further guides on how the leverage push2cloud can be found on Github.
An example app on how to integrate with non javascript apps can be found here.

To learn more about push2cloud, join us at the next Cloud Foundry User Group Meetup and bring your own app to get push2cloud ready.


Leave a Reply

Your email address will not be published. Required fields are marked *