Jump to content
We've recently updated our Privacy Statement, available here ×
  • Deploying JasperReports Server on AWS ECS with Fargate


    jpadre
    • Edited on:
    • Features: JasperReports Server Version: v8 Product: JasperReports® Server

    Introduction

    This article provides the steps to deploy JasperReports Server on Amazon Elastic Container Service (AWS ECS) with Fargate. 

    Pre-requisites 

    • EC2 instance - Amazon Linux to build and publish images:
      • Docker and Docker-Compose installed.
      • AWS CLI installed to push images into the registry. (To push your images to AWS ECR, create a new AWS ECR registry.)
      • RDS access
      • Amazon EFS client (amazon-efs-utils) installed.
    • Create an ECS cluster- select Networking only.
    • Create 5 security groups for ECS services:
      • Load balancer security group - allow inbound connections on TCP port 8080 for network
      • JRS webapp service security group - allow inbound connections on TCP port 8080 from load balancer security group
      • activemq service security group - allow inbound connections on TCP port 61616 from JRS webapp security group
      • RDS security group - allow inbound connections on port TCP 5432 from JRS webapp security group, also allow connections on the same port for EC2 instance which will be used to build images
      • EFS security group - allow inbound NFS on port 2049 from JRS webapp security group
    • Create an EFS that will be used to store Keystore and license.
    • Configure an RDS for repository setup:
      • Use PostgreSQL 12 db.
      • Use created RDS security group.
    • Create the load balancer and target group for JRS service:
      • Fargate target groups should have type - IP, forward to port 8080
      • Target Health Checks:
        • protocol - HTTP
        • path - /jasperserver-pro/login.html
        • port - traffic port (default)
        • healthy threshold - 2
        • unhealthy threshold - 10
        • timeout - 50s
        • interval - 90s (increase it if JRS starts slower due to container resource limits)
        • success code - 200
      • Enable sticky sessions for target - find your target and edit attributes:
        • Enable Stickiness
        • Select Application-based cookie
        • Stickiness duration - 1 day
        • App cookie name - JSESSIONID

    NOTE : If using new AWS UI, use the following steps to enable sticky notes:

    1. Go to EC2.
    2. Go to created target group.
    3. Click on target group.
    4. Click Attributes to edit it.
    5. Enable Stickiness and fill in the details.
    6. ALB will listen on port 8080 and will forward to the target group.

    NOTE: RDS, EFS, LB, and ECS cluster should be in the same VPC.

    Installation and Deployment Steps

    1. Installer setup: 

    Have an EC2 instance (or machine where you have docker installed), clone the js-docker repository and download Jaspersoft installer. For more information, refer to: https://github.com/TIBCOSoftware/js-docker/tree/main/jaspersoft-containers/Docker/jrs#installer-setup

    2. Build Docker images: 

    Note: Ensure you have an RDS instance running and that you have updated the default_master.properties file by setting RDS endpoint as dbHost, dbUsername, dbPassword

    To build webapp and buildomatic Docker images using docker-compose, follow the steps from https://github.com/TIBCOSoftware/js-docker/tree/main/jaspersoft-containers/Docker/jrs#building-the-images.

    3. Keystore generation:

    If you already have keystore files, you can ignore this step. If you want to generate new keystore files, follow the steps from https://github.com/TIBCOSoftware/js-docker/tree/main/jaspersoft-containers/Docker/jrs#keystore-generation

    4. Repository Setup:

    To configure the repository database, follow the steps from https://github.com/TIBCOSoftware/js-docker/tree/main/jaspersoft-containers/Docker/jrs#repository-setup

    5. Push Webapp Docker image to AWS ECR:

    Tag the jasperserver-webapp Docker image and push it onto AWS ECR.

    Note: Even though the docker-compose build command generates two images, jasperserver-webapp and jasperserver-buildomatic, it's only necessary to push the jasperserver-webapp image to AWS ECR since the DB configuration is taken care in step 4 above and no task definition is created for it. 

    6. Create an EFS storage to store keystore and license files:

    1. Create an EFS and mount it on EC2 instance:

                      i. Go to created EFS.

                      ii. Click on EFS that is going to be used for testing.

                      iii. Click on Attach button. 

                      iv. Copy NFS client mount command. 

                      v. SSH to EC2 instance, in root, use above mount command.

    2. Create a keystore folder and copy the keys .jrsks and .jrsksp under that folder.
    3. Change the permissions to 666 for Keystore files, run: sudo chmod -R 666 .jrs*.
    4. Create a license folder and copy jasperserver.license to that folder, run: chmod 666 jasperserver.license

    keystore-example-jrs-aws-ecs-fargate.png

    7. Create a Task Definition for ActiveMQ:

    1. Create a new Task Definition.
    2. Select the Fargate launch type.
    3. Select the Network mode as awsvpc.
    4. Select the Task execution role.
    5. Select the task size as per your requirement; for example: task memory 0.5GB, task CPU 0.25 vcpu .
    6. Select Add container.
      1. Provide the Container name (can be any).
      2. Provide the activemq image in image field ex: rangareddyv/activemq-openshift:5.16.2.
      3. Under port mappings, make Container port as 61616 and Protocol as tcp.
    7. Proceed with Create task definition.

    8. Create a Service for ActiveMQ:

        1. Go to Services and select Create under the cluster.

        2. Select the Fargate launch type.

        3. Under Task definition select the task definition name of activemq. (Select the Task Definition created above.)

        4. Select the cluster name and provide a service name. 

        5. Number of Tasks: 1

        6. Select the VPC and subnets (Note: VPC should be same for all.)

        7. Select security group created for ActiveMQ service.

        8. Auto assign public IP to Enabled.

        9. Select the Load balancing type to None.

        10. Enable Service Discovery:

              a. Configure cross-task communication between the JasperReports Server and ActiveMQ containers.

              b. Provide the Namespace and service discovery name, endpoint will be : service discovery name.namespace_name

                  For example:

                     Namespace: jrs

                     Service name: active

                     Service discovery endpoint: active.jrs

        11. Create the Service.

    9. Create a Task Definition for jasperserver-webapp:

    It will connect to a JasperReports Server repository running in RDS.

    Use the EFS volume to load Keystore files and license:

    1. Create a new Task Definition.
    2. Select the Fargate launch type.
    3. Select the Network mode as awsvpc.
    4. Select the Task execution role.
    5. Select the task size as per your requirement; for example: task memory 4GB, task CPU 2 vcpu.
    6. Under Volumes, add Volume:
      1. Provide the name and select the type as efs.
      2. Select the File system ID in the drop-down where the Keystore and license are in efs.
      3. Select the Root directory as root and Add.
    7. Select Add container.
    8. Provide the Container name (can be any).
    9. Provide the URL of the jasperserver-webapp image in your ECR repository in the image field.
    10. In Port mappings, set the Container port to 8080 and the protocol to TCP.
    11. Add to the Environment variables:
      1. JAVA_OPTS    -XX:+UseContainerSupport -XX:MinRAMPercentage=33.0 -XX:MaxRAMPercentage=75.0 -Djs.license.directory=/usr/local/share/jasperserver-pro/license -Djasperserver.cache.jms.provider=tcp://{{service discovery endpoint of activemq}}:61616 .ex: tcp://activemq.jrs:61616.
    12. Add Storage and logging:
      1. Select the volume name from drop-down. 
      2. Make the path as /usr/local/share/jasperserver-pro
    13. Create the Task definition.

    10. Create a Service for jasperserver-webapp:

    1. Go to your cluster and select create under service.
    2. Select the Fargate launch type.
    3. Under Task definition, select the task definition name of jasperserver-webapp. (Select the Task Definition created above.)
    4. Select the cluster name and provide a service name. 
    5. Number of Tasks: 1
    6. Select the VPC and subnets (Note: VPC should be same for all).
    7. Auto assign public IP to Enabled.
    8. Under Load balancing, select the load balancer type as Application Load Balancer.
    9. Select your load balancer from the drop-down.
    10. Under Container at Load Balance, select Add to a load balancer.
    11. Select your listener port and Target group that was previously created from the drop-down.
    12. Create the service.

    11. Configure Security groups:

    Allow Load Balancer to access ECS service.

    1. Add Load Balancer security group all traffic access to service in webapp-service security group.
    2. Add webapp-service security group to RDS in RDS security group.
    3. Make sure that EFS security group allows inbound NFS on port 2049 from webapp-service security group
    4. Update the Security Group used by the ActiveMQ service to allow TCP traffic on port 61616 for webapp-service security group.

    Accessing JasperReports Server

    Login using the load balancer.

    http://<IP or DNS of Load Balancer>:8080/jasperserver-pro

     


    User Feedback

    Recommended Comments

    There are no comments to display.



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...