Article

Deploy a web application with IBM WebSphere Liberty on Amazon EKS

Use IBM WebSphere Liberty with AWS container services

By

Tejaskumar Shah

IBM WebSphere Liberty is a fast, secure cloud-native Java runtime that is built on the open source Open Liberty project. Liberty is ideal for deploying containerized cloud-native Java applications to Kubernetes environments, such as Amazon Elastic Kubernetes Service (EKS). This article shows you how to deploy a cloud-native Java application to an Amazon EKS cluster. You can also deploy your application to Amazon Elastic Container Service (ECS), Red Hat OpenShift Service on AWS (ROSA), or a self-managed OpenShift instance.

How Liberty can help developers in the cloud

Many enterprises are moving their applications to the cloud in order save on hosting costs. In the cloud, they can pay for only the resources their applications are using, rather than paying for 24/7 hosting in their own data centers. In moving to the cloud, enterprises are modernizing some of their existing applications by refactoring them from larger, monolithic applications to smaller, more modular applications, which are more suited to the rapid scaling requirements of the cloud. For other applications, though, enterprises are simply starting to develop fresh, cloud-native applications from scratch. In either scenario, developers can easily write and build their applications using Liberty and its tools, and then containerize the applications to deploy them to Kubernetes clusters.

WebSphere Liberty supports the standards-based MicroProfile, Java EE, and Jakarta EE APIs, and is ideal for both writing new cloud-native applications and modernizing existing applications. As a developer, you can write and test your applications on WebSphere Liberty or on Open Liberty and then deploy to either runtime in production. Both runtimes are production-ready with support available from IBM.

IBM and Amazon provide a Partner Solution (formerly known as Quick Start) called IBM WebSphere Liberty for Amazon EKS, which allows you to deploy WebSphere Liberty or Open Liberty applications under the WebSphere Trial/Production license. The solution deploys an IBM WebSphere Liberty operator to an Amazon EKS cluster in the Amazon Web Services cloud. This enables you to deploy a sample Java application or your own Java application(s) to a highly available architecture in the cloud in the cloud where your application runs on WebSphere Liberty or Open Liberty. You can then run Day 2 operations using WebSphere Liberty’s monitoring, tracing, and logging capabilities.

To deploy applications on WebSphere Liberty for Amazon EKS, you must have a valid license to use WebSphere Liberty. If you have already purchased an IBM product such as WebSphere Application Server, IBM WebSphere Hybrid Edition, or WebSphere Application Server Family Edition, you are entitled to use WebSphere Liberty.

Why use WebSphere Liberty?

There are numerous reasons to use WebSphere Liberty for cloud as it provides many features as listed below.

  1. Developer tools: Liberty integrates with the most popular build tools -- Maven and Gradle -- including releasing all the runtime binaries to Maven Central. Liberty’s Maven and Gradle support also provides dev mode support.

  2. Right-sized runtime: Liberty is a fully modular runtime that lets you pick and choose the capabilities you need for your application.

  3. Kubernetes optimized: To get the best performance out of the application in containers, Liberty does two things:

    • It provides great defaults that you probably won't ever have to change.
    • It provides an auto-tuning thread pool that optimizes for the environment where it is currently running.
  4. Continuous delivery: Liberty has a continuous delivery release cycle, which means it ships a new release every four weeks. Any fixes shipped for the previous release are automatically rolled into the next. So with continuous delivery, there’s no need to apply service -- you get it automatically. Every release of Liberty is made available in Maven Central and Docker Hub.

  5. Low operating cost: Liberty has significant memory, performance, and throughput benefits when compared to other runtimes, and it provides a 100% open source Java EE, Jakarta EE, and MicroProfile core.

  6. Zero migration: In just a matter of minutes, you can move up to the latest version of Liberty without having to change your application code or configuration.

Due to the above-mentioned features, WebSphere Liberty is a performant runtime that's suitable for containerized applications, and it has a wide range of use cases.

Enterprises use Java, and WebSphere Liberty and its predecessor, WebSphere Application Server, are used by many of the largest businesses around the world and across a broad set of industries.

Deploy a cloud-native application with WebSphere Liberty on AWS

Cloud-native applications are designed and written to run on the cloud. Kubernetes is a popular container orchestration tool for many enterprises.

Amazon EKS is a managed service that runs Kubernetes in the AWS cloud, and WebSphere Liberty is a runtime that is packaged with a Java application in a container to run on Kubernetes.

The following diagram shows the architecture that is set up by the WebSphere Liberty for Amazon EKS Partner Solution ready for you to deploy an application:

Architecture: WebSphere Liberty for Amazon EKS Partner Solution

The architecture enables high availability (HA) by spanning resources across two availability zones so that deployed applications can survive a single availability zone failure. It can be made even more resilient by using three availability zones. Furthermore, it can achieve horizontal scaling as the application itself can be scaled by spinning up new application pods using the WebSphere Liberty Operator.

The architecture is secure because it uses an EKS cluster in a private network. The application pods run in nodes and those nodes are placed in a private subnet of a VPC, so that the nodes and pods are not directly accessible from the internet. The load balancer is placed in a public subnet to enable public internet access and to load balance requests across availability zones.

The WebSphere Liberty Operator is a Kubernetes operator that is used for deploying and managing WebSphere Liberty applications. The operator uses Custom Resource Definitions (CRD) with a kind as "WebSphereLibertyApplication" to describe the deployment of such applications. The WebSphere Liberty Operator provides a scalability feature by providing an "autoscaling" field in the specification of the application. The autoscaling features work as a pod auto scaler for applications. The cert-manager is required to install and manage certificates for Kubernetes applications.

The sample application

Developing an application with WebSphere Liberty requires a containerized application image that you can build from the official WebSphere Liberty image, which is available from the IBM container registry (recommended) or DockerHub. For example, the container image that uses the official IBM container registry can be built by including icr.io/appcafe/websphere-liberty:<tag> in a Dockerfile.

For the purposes of this article, you will use a sample application that was written to run on Open Liberty, and you will modify the build to use WebSphere Liberty and verify it.

  1. Prerequisites: Install Java, Maven, Git, and Podman.

  2. Clone the sample application:

    git clone https://github.com/openliberty/guide-getting-started.git
    cd guide-getting-started
    cd finish
    
  3. Edit the application’s pom.xml file to use WebSphere Liberty from Maven Central. Add the following runtime artifact configuration to the pom.xml:

    <plugin>
           <groupId>io.openliberty.tools</groupId>
           <artifactId>liberty-maven-plugin</artifactId>
           <version>3.7.1</version>
           <configuration>
              <runtimeArtifact>
              <groupId>com.ibm.websphere.appserver.runtime</groupId>
              <artifactId>wlp-kernel</artifactId>
              </runtimeArtifact>
           </configuration>
    </plugin>
    
  4. Build a WAR file:

    mvn package
    
  5. Create a Dockerfile. Replace the application's existing Dockerfile with following one, to use the WebSphere Liberty runtime:

    FROM icr.io/appcafe/websphere-liberty:kernel-java11-openj9-ubi
    
    COPY --chown=1001:0 src/main/liberty/config/server.xml  /config/
    COPY --chown=1001:0 target/*.war  /config/apps/
    
    RUN configure.sh
    
  6. Build an application container image:

    podman build -t websphere-getting-started
    
  7. Run the application to verify that the image is what you built in the previous step:

    podman run --name websphere-getting-started --rm -p 9080:9080 websphere-getting-started
    
  8. Stop the application by pressing CTRL+C.

  9. Publish the sample application to a container registry so that later on you can use it for deployment to the EKS cluster. You can publish the application to any container registry as per your organization's guidelines. You can also publish the image to ECR as per the steps for pushing an image to ECR. Once an image is successfully pushed, you can view the image details from the AWS Console for verification.

You're now ready to provision an EKS cluster and deploy your WebSphere Liberty application on it:

  1. Provision an EKS cluster with WebSphere application by using IBM WebSphere Liberty for Amazon EKS Partner Solution.

    The Partner Solution provisions all of the essential resources and deploys the WebSphere Liberty application on the EKS cluster. To do this, it installs the Operator Lifecycle Manager, the WebSphere Liberty Operator, the WebSphere Liberty application, and the cert manager.

    To deploy the WebSphere Liberty application, you need to provide the image URI of the sample application that you built as an input to the partner solution.

    Also, the partner solution can deploy a sample application that’s pre-built and is available in the IBM Cloud Container Registry.

  2. Verify the application by launching the endpoint that's created using the Classic Load Balancer, which is provided by the AWS Partner Solution.

  3. Install IBM License Operator to track usage of the application. The IBM Licensing Operator installs the IBM License service which tracks and reports the usage of WebSphere Liberty in the Kubernetes cluster.

    You have now deployed and are running the sample WebSphere Liberty application on an Amazon EKS Kubernetes cluster. You can now deploy the cluster autoscaler if you need vertical scaling of nodes, and application load balancer if you need benefits such as host/path-based routing.

  4. The previously installed WebSphere Liberty Operator helps to scale the application instance itself. If you need to scale the virtual instance (VM)/node itself, install the Cluster AutoScaler.

  5. If you have multiple SSL certificate requirements or need advanced features such as path/host-based routing or header-based routing, then provision Application Load Balancer along with the installation of AWS Load Balancer Controller.

Summary and next steps

In this article, you have learned that the IBM WebSphere Liberty provides a Kubernetes optimized runtime that can be used as a runtime for small- to large-scale Java-based microservices.

You walked through steps for developing cloud-native WebSphere Liberty applications and built a sample application image with WebSphere Liberty. As you progressed, you explored an architecture that showcased WebSphere Application Server app deployment in AWS EKS by following the well-architected pillars of AWS. Finally, you deployed the WebSphere Liberty application to the Amazon EKS cluster by using the IBM and Amazon provided Partner Solution on EKS for accelerated deployment.

You can find out more about how WebSphere Liberty offers tremendous benefits to organizations and developers in the article "6+3 Reasons Why Liberty is the Runtime for Hybrid Cloud ."

If you’d like to find out more about the IBM WebSphere Liberty for EKS Partner Solution and see it demonstrated by the team that created it, register for the upcoming webinar.

Acknowledgements

The author wishes to thank Shane O’Rourke, Graham Charters, Ranjan Kumar, and Laura Cowen for reviewing this article and providing constructive feedback.

About the IBM AWS partnership

For companies looking to enable and accelerate their customers' hybrid cloud journey by leveraging AWS’ cloud platform, IBM brings leading-edge technologies and expertise on AWS through a unique combination of IBM Consulting, Software, and as-a-service capabilities. From concept to scale, our end-to-end solutions and proven methods help companies modernize their applications and infrastructure with speed and consistency so businesses stay ahead of the curve.

Image shows IBM and AWS logos