Building Blue/Green application deployment to Micro Focus Enterprise Server
Organizations running mainframe production workloads often follow the traditional approach of application deployment. To release new features of existing applications into production, the application is redeployed using the new version of software on the existing infrastructure. This poses the following challenges:
- The cutover of the application deployment from testing to production usually takes place during a planned outage window with associated downtime.
- Rollback is difficult, since the earlier version of the software must be redeployed from scratch on the existing infrastructure. This may result in applications being unavailable for longer durations owing to the rollback.
- Due to differences in testing and production environments, some defects may leak into production, affecting the application code quality and thus increasing the number of production outages
Automated, robust application deployment is recognized as a prime driver for moving from a Mainframe to AWS, as service stability, security, and quality can be better managed. In this post, you will learn how to build Blue/Green (zero-downtime) deployments for mainframe applications rehosted to Micro Focus Enterprise Server with AWS Developer Tools (AWS CodeBuild, CodePipeline, and CodeDeploy).
This is a continuation of our previous post “Automate thousands of mainframe tests on AWS with the Micro Focus Enterprise Suite”. In our last post, we explained how you can implement a pattern for continuous integration and testing of mainframe applications with AWS Developer tools and Micro Focus Enterprise Suite. If you haven’t already checked it out, then we strongly recommend that you read through it before proceeding to the rest of this post.
Overview of solution
In this section, we explain the three important design “ingredients” to be implemented in the overall solution:
- Implementation of Enterprise Server Performance and Availability Cluster (PAC)
- End-to-end design of CI/CD pipeline for multiple teams development
- Blue/green deployment process for a rehosted mainframe application
First, let’s look at the solution design for the Micro Focus Enterprise Server PAC cluster.
Overview of Micro Focus Enterprise Server Performance and Availability Cluster (PAC)
In the Blue/Green deployment solution, Micro Focus Enterprise Server is the hosting environment for mainframe applications with the software installed into Amazon EC2 instances. Application deployment in Amazon EC2 Auto Scaling is one of the critical requirements to build a Blue/Green deployment. Micro Focus Enterprise Server PAC technology is the feature that allows for the Auto Scaling of Enterprise Server instances. For details on how to build Micro Focus Enterprise PAC Cluster with Amazon EC2 Auto Scaling and Systems Manager, see our AWS Prescriptive Guidance document. An overview of the infrastructure architecture is shown in the following figure, and the following table explains the components in the architecture.
|Micro Focus Enterprise Servers||Deploy applications to Micro Focus Enterprise Servers PAC in Amazon EC2 Auto Scaling Group.|
|Micro Focus Enterprise Server Common Web Administration (ESCWA)||Manage Micro Focus Enterprise Server PAC with ESCWA server, e.g., Adding or Removing Enterprise Server to/from a PAC.|
|Relational Database for both user and system data files||Setup Amazon Aurora RDS Instance in Multi-AZ to host both user and system data files to be shared across the Enterprise server instances.|
|Micro Focus Enterprise Server Scale-Out Repository (SOR)||Setup an Amazon ElastiCache Redis Instance and replicas in Multi-AZ to host user data.|
|Application endpoint and load balancer||Setup a Network Load Balancer to provide a hostname for end users to connect the application, e.g., accessing the application through a 3270 emulator.|
CI/CD Pipelines design supporting multi-streams of mainframe development
In a previous DevOps post, Automate thousands of mainframe tests on AWS with the Micro Focus Enterprise Suite, we introduced two levels of pipelines. The first level of pipeline is used by mainframe project teams to test project scope changes. The second level of the pipeline is used for system integration tests, where the pipeline will perform tests for all of the promoted changes from the project pipelines and perform extensive systems tests.
In this post, we are extending the two levels pipeline to add a production deployment pipeline. When system testing is complete and successful, the tested application artefacts are promoted to the production pipeline in preparation for live production release. The following figure depicts each stage of the three levels of CI/CD pipeline and the purpose of each stage.
Let’s look at the artifact promotion to production pipeline in greater detail. The Systems Test Pipeline promotes the tested artifacts in binary format into an Amazon S3 bucket and the S3 event triggers production pipeline to kick-off. This artifact promotion process can be gated using a manual approval action in CodePipeline. For customers who want to have a fully automated continuous deployment, the manual promotion approval step can be removed.
The following diagram shows the AWS Stages in AWS CodePipeline of the production deployment pipeline:
After the production pipeline is kicked off, it downloads the new version artifact from the S3 bucket. See the details of how to setup the S3 bucket as a Source of CodePipeline in the document AWS CodePipeline Document S3 as Source.
In the following section, we explain each of these pipeline stages in detail:
- It prepares and packages a new version of production configuration artifacts, for example, the Micro Focus Enterprise Server config file, blue/green deployment scripts etc.
- Use in the CodeBuild Project to kick off an application blue/green deployment with AWS CodeDeploy.
- Use a manual approval gate to wait for an operator to validate the new version of the application and approve to continue the production traffic switch
- Continue the blue/green deployment by allowing traffic to the new version of the application and block the traffic to the old version.
- After a successful Blue/Green switch and deployment, tag the production version in the code repository.
Now that you’ve seen the pipeline design, we will dive deep into the details of the blue/green deployment with AWS CodeDeploy.
Blue/green deployment with AWS CodeDeploy
In the blue/green deployment, we used the technique of swapping Auto Scaling Group behind an Elastic Load Balancer. Refer to the AWS Blue/Green deployment whitepaper for the details of the technique. As AWS CodeDeploy is a fully-managed service that automates software deployment, it is used to automate the entire Blue/Green process.
Firstly, the following best practices are applied to setup the Enterprise Server’s infrastructure:
- AWS Image Builder is used to install Micro Focus Enterprise Server software and AWS CodeDeploy Agent into Amazon Machine Image (AMI). Create an EC2 Launch Template with the Enterprise Server AMI ID.
- A Network Load Balancer is used to setup a TCP connection health check to validate that Micro Focus Enterprise Server is listening on the required ports, e.g., port 9270, so that connectivity is available for 3270 emulators.
- A script was created to confirm application deployment validity in each EC2 instance. This is achieved by using a PowerShell script that triggers a CICS transaction from the Micro Focus Enterprise Server command line interface.
In the CodePipeline, we created a CodeBuild project to create a new deployment with CodeDeploy. We will go into the details of the CodeBuild buildspec.yaml configuration.
In the CodeBuild buildspec.yaml’s pre_build section, we used the following steps:
In the pre-build stage, the CodeBuild will perform two steps:
- Create an initial Amazon EC2 Auto Scaling using Micro Focus Enterprise Server AMI and a Launch Template for the first-time deployment of the application.
- Use AWS CLI to update the initial Auto Scaling Group name into a Systems Manager Parameter Store, and it will later be used by CodeDeploy to create a copy during the blue/green deployment.
In the build stage, the buildspec will perform the following steps:
- Retrieve the Auto Scaling Group name of the Enterprise Servers from the Systems Manager Parameter Store.
- Then, a blue/green deployment configuration is created for the deployment group of the application. In the AWS CLI command, we use the WITH_TRAFFIC_CONTROL option to let us manually verify and approve before switching the traffic to the new version of the application. The command snippet is shown here.
- Next, the new version of application binary is released from the CodeBuild source DemoBinto the production S3 bucket.
- Create a new deployment for the application to initiate the Blue/Green switch.
After setting up the deployment options, the following is a snapshot of a deployment configuration from the AWS Management Console.
In the AWS Post “Under the Hood: AWS CodeDeploy and Auto Scaling Integration”, we explain how AWS CodeDeploy sets up Auto Scaling lifecycle hooks to listen for Auto Scaling events. In the event of an EC2 instance launch and termination, AWS CodeDeploy can instruct its agent in the instance to run the prepared scripts.
In the following table, we list each stage in a blue/green deployment and the tasks that ran.
|BeforeInstall||Create application folder structures in the newly launched Amazon EC2 and prepare for installation|
|AfterInstall||Enable Windows Firewall Rule for application traffic|
|Activate Micro Focus License using License Server|
|Prepare Production Database Connections|
|Import config to create Region in Micro Focus Enterprise Server|
|Deploy the latest application binaries into each of the Micro Focus Enterprise Servers|
|ApplicationStart||Use AWS CLI to start a Systems Manager Automation “Scale-Out” runbook with the target of ESCWA server|
|The Automation runbook will add the newly launched Micro Focus Enterprise Server instance into a PAC|
|The Automation runbook will start the imported region in the newly launched Micro Focus Enterprise Server|
|Validate that the application is listening on a service port, for example, port 9270|
|Use the Micro Focus command “castran” to run an online transaction in Micro Focus Enterprise Server to validate the service status|
|AfterBlockTraffic||Use AWS CLI to start a Systems Manager Automation “Scale-In” runbook with the target ESCWA server|
|The Automation runbook will try stopping the Region in the terminating EC2 instance|
|The Automation runbook will remove the Enterprise Server instance from the PAC|
The tasks in the table are automated using PowerShell, and the scripts are used in appspec.yml config for CodeDeploy to orchestrate the deployment.
In the following appspec.yml, the locations of the binary files to be installed are defined in addition to the Micro Focus Enterprise Server Region XML config file. During the AfrerInstall stage, the XML config is imported into the Enterprise Server.
Using the sample Micro Focus Bankdemo application, and the steps outlined above, we have setup a blue/green deployment process in Micro Focus Enterprise Server.
There are four important considerations when setting up blue/green deployment:
- For batch applications, the blue/green deployment should be invoked only outside of the scheduled “batch window”.
- For online applications, AWS CodeDeploy will deregister the Auto Scaling group from the target group of the Network Load Balancer. The deregistration may take a while as the server has to finish processing the ongoing requests before it can continue deployment of the new application instance. In this case, enabling Elastic Load Balancing connection draining feature with appropriate timeout value can minimize the risk of closing unfinished transactions. In addition, consider doing deployment in low-traffic windows to improve the deployment speeds.
- For application changes that require updates to the database schema, the version roll-forward and rollback can be managed via DB migrations tools, e.g., Flyway and Fluent Migrator.
- For testing in production environments, adherence to any regulatory compliance, such as full audit trail of events, must be considered.
In this post, we introduced the solution to use Micro Focus Enterprise Server PAC, Amazon EC2 Auto Scaling, AWS Systems Manager, and AWS CodeDeploy to automate the blue/green deployment of rehosted mainframe applications in AWS.
Through the blue/green deployment methodology, we can shift traffic between two identical clusters running different application versions in parallel. This mitigates the risks commonly associated with mainframe application deployment, namely downtime and rollback capacity, while ensure higher code quality in production through “Shift Right” testing.
A demo of the solution is available on the AWS Partner Micro Focus website [Solution-Demo]. If you’re interested in modernizing your mainframe applications, then please contact Micro Focus and AWS mainframe business development at email@example.com.
- AWS Blue Green deployment whitepaper
- AWS Prescriptive Guidance – Build a Micro Focus Enterprise Server PAC with Amazon EC2 Auto Scaling and Systems Manager
- AWS Prescriptive Guidance – Mainframe modernization: DevOps on AWS with Micro Focus
- AWS DevOps Blog – Automate thousands of mainframe tests on AWS with the Micro Focus Enterprise Suite