AWS News Blog
AWS App2Container – A New Containerizing Tool for Java and .NET Applications
|
Our customers are increasingly developing their new applications with containers and serverless technologies, and are using modern continuous integration and delivery (CI/CD) tools to automate the software delivery life cycle. They also maintain a large number of existing applications that are built and managed manually or using legacy systems. Maintaining these two sets of applications with disparate tooling adds to operational overhead and slows down the pace of delivering new business capabilities. As much as possible, they want to be able to standardize their management tooling and CI/CD processes across both their existing and new applications, and see the option of packaging their existing applications into containers as the first step towards accomplishing that goal.
However, containerizing existing applications requires a long list of manual tasks such as identifying application dependencies, writing dockerfiles
, and setting up build and deployment processes for each application. These manual tasks are time consuming, error prone, and can slow down the modernization efforts.
Today, we are launching AWS App2Container, a new command-line tool that helps containerize existing applications that are running on-premises, in Amazon Elastic Compute Cloud (Amazon EC2), or in other clouds, without needing any code changes. App2Container discovers applications running on a server, identifies their dependencies, and generates relevant artifacts for seamless deployment to Amazon Elastic Container Service (Amazon ECS) and EKS. It also provides integration with AWS CodeBuild and AWS CodeDeploy to enable a repeatable way to build and deploy containerized applications.
AWS App2Container generates the following artifacts for each application component: Application artifacts such as application files/folders, Dockerfiles, container images in Amazon Elastic Container Registry (Amazon ECR) (ECR), ECS Task definitions, Kubernetes deployment YAML, CloudFormation templates to deploy the application to Amazon ECS or EKS, and templates to set up a build/release pipeline in AWS Codepipeline which also leverages AWS CodeBuild and CodeDeploy.
Starting today, you can use App2Container to containerize ASP.NET (.NET 3.5+) web applications running in IIS 7.5+ on Windows, and Java applications running on Linux—standalone JBoss, Apache Tomcat, and generic Java applications such as Spring Boot, IBM WebSphere, Oracle WebLogic, etc.
By modernizing existing applications using containers, you can make them portable, increase development agility, standardize your CI/CD processes, and reduce operational costs. Now let’s see how it works!
AWS App2Container – Getting Started
AWS App2Container requires that the following prerequisites be installed on the server(s) hosting your application: AWS Command Line Interface (AWS CLI) version 1.14 or later, Docker tools, and (in the case of ASP.NET) Powershell 5.0+ for applications running on Windows. Additionally, you need to provide appropriate IAM permissions to App2Container to interact with AWS services.
For example, let’s look how you containerize your existing Java applications. App2Container CLI for Linux is packaged as a tar.gz
archive. The file provides users an interactive shell script, install.sh
to install the App2Container CLI. Running the script guides users through the install steps and also updates the user’s path to include the App2Container CLI commands.
First, you can begin by running a one-time initialization on the installed server for the App2Container CLI with the init
command.
This sets up a workspace to store application containerization artifacts (minimum 20GB of disk space available). You can extract them into your Amazon Simple Storage Service (Amazon S3) bucket using your AWS profile configured to use AWS services.
Next, you can view Java processes that are running on the application server by using the inventory
command. Each Java application process has a unique identifier (for example, java-tomcat-9e8e4799
) which is the application ID. You can use this ID to refer to the application with other App2Container CLI commands.
You can also intialize ASP.NET applications on an administrator-run PowerShell session of Windows Servers with IIS version 7.0 or later. Note that Docker tools and container support are available on Windows Server 2016 and later versions. You can select to run all app2container operations on the application server with Docker tools installed or use a worker machine with Docker tools using Amazon ECS-optimized Windows Server AMIs.
The inventory
command displays all IIS websites on the application server that can be containerized. Each IIS website process has a unique identifier (for example, iis-smarts-51d2dbf8
) which is the application ID. You can use this ID to refer to the application with other App2Container CLI commands.
You can choose a specific application by referring to its application ID and generate an analysis report for the application by using the analyze
command.
You can use the analysis.json
template generated by the application analysis to gather information on the analyzed application that helps identify all system dependencies from the analysisInfo
section, and update containerization parameters to customize the container images generated for the application using the containerParameters
section.
Also, you can run the $ app2container extract --application-id java-tomcat-9e8e4799
command to generate an application archive for the analyzed application. This depends on the analysis.json
file generated earlier in the workspace folder for the application,and adheres to any containerization parameter updates specified in there. By using extract
command, you can continue the workflow on a worker machine after running the first set of commands on the application server.
Now you can containerize command generated Docker images for the selected application.
Using this command, you can view the generated container images using Docker images on the machine where the containerize command is run. You can use the docker run
command to launch the container and test application functionality.
Note that in addition to generating container images, the containerize
command also generates a deployment.json
template file that you can use with the next generate-appdeployment
command. You can edit the parameters in the deployment.json
template file to change the image repository name to be registered in Amazon ECR, the ECS task definition parameters, or the Kubernetes App name.
At this point, the application workspace where the artifacts are generated serves as an iteration sandbox. You can choose to edit the Dockerfile
generated here to make changes to their application and use the docker build
command to build new container images as needed. You can generate the artifacts needed to deploy the application containers in Amazon EKS by using the generate-deployment
command.
This command works based on the deployment.json
template file produced as part of running the containerize
command. App2Container will now generate ECS/EKS cloudformation templates as well and an option to deploy those stacks.
The command registers the container image to user specified ECR repository, generates cloudformation template for Amazon ECS and EKS deployments. You can register ECS task definition with Amazon ECS and use kubectl
to launch the containerized application on the existing Amazon EKS or self-managed kubernetes cluster using App2Container generated amazon-eks-master.template.deployment.yaml
.
Alternatively, you can directly deploy containerized applications by --deploy
options into Amazon EKS.
Handling ASP.NET Applications with Windows Authentication
Containerizing ASP.NET applications is almost same process as Java applications, but Windows containers cannot be directly domain joined. They can however still use Active Directory (AD) domain identities to support various authentication scenarios.
App2Container detects if a site is using Windows authentication and accordingly makes the IIS site’s application pool run as the network service identity, and generates the new cloudformation templates for Windows authenticated IIS applications. The creation of gMSA and AD Security group, domain join ECS nodes and making containers use this gMSA are all taken care of by those templates.
Also, it provides two PowerShell scripts as output to the $ app2container containerize
command along with an instruction file on how to use it.
The following is an example output:
The first PowerShellscript, DomainJoinAddToSecGroup.ps1
, joins the container host and adds it to an Active Directory security group. The second script, CreateCredSpecFile.ps1
, creates a Group Managed Service Account (gMSA), grants access to the Active Directory security group, generates the credential spec for this gMSA, and stores it locally on the container host. You can execute these PowerShellscripts on the ECS host. The following is an example usage of the scripts:
Before executing the app2container generate-deployment
command, edit the deployment.json
file to change the value of dockerSecurityOption
to the name of the CredentialSpec
file that the CreateCredSpecFile
script generated. For example,
"dockerSecurityOption": "credentialspec:file://dominion_mygmsaforiis.json"
Effectively, any access to network resource made by the IIS server inside the container for the site will now use the above gMSA to authenticate. The final step is to authorize this gMSA account on the network resources that the IIS server will access. A common example is authorizing this gMSA inside the SQL Server.
Finally, if the application must connect to a database to be fully functional and you run the container in Amazon ECS, ensure that the application container created from the Docker image generated by the tool has connectivity to the same database. You can refer to this documentation for options on migrating: MS SQL Server from Windows to Linux on AWS, Database Migration Service, and backup and restore your MS SQL Server to Amazon RDS.
Now Available
AWS App2Container is offered free. You only pay for the actual usage of AWS services like Amazon EC2, ECS, EKS, and S3 etc based on their usage. For details, please refer to App2Container FAQs and documentations. Give this a try, and please send us feedback either through your usual AWS Support contacts, on the AWS Forum for ECS, AWS Forum for EKS, or on the container roadmap on Github.
— Channy;