- AWS Fargate is a compute engine for ECS.
- Allows To run containers without having supervision and configure and scale the cluster of VM’s that host container application.
- Create a docker image of your spring boot application is in the referred code.
- Add the image to your docker hub.
- We can also use Elastic Container Registry (ECR) service.
- Go to ECS service on your AWS account.
- Click on get started.
- We see a diagram which Shows cluster as top most component.
- Cluster contains service.
- Service contains task definitions.
- Task definition contains container definition.
- Task definition is a text file in Jason format that describes one or more containers that form our application. It is a blueprint of our application.
- A docker container is a standard unit of software development which contains Everything which our application needs to run along with some random system tools and libraries. Containers are created from read only template called as container images.
- Our application creates the service which we use.
- Cluster is logical grouping of resources that our application needs.
- Amazon ECS manages our cluster resources.
- Select custom container configuration from ECS Container and task definition.
- In the image specify your docker image pull command As follows.
- docker.io/gauravmatta/springboot-aws-ecs
- Select memory limit.
- Select port mapping.
- We can also add health check configuration if needed.
- Click update to update container configuration.
- Change task definition if needed
- Click next
- Customized service configuration
- Configure load balancer.
- Configure cluster
- Review and click create.
- This will create our task now to run the task we need to create a cluster.
- Click on create cluster in clusters tab
- Select networking only cluster This is the Fargate cluster.
- Provide name and click create.
- Click on tasks under the new cluster.
- Select launch type as Fargate.
- Enter the task definition
- Select cluster of task.
- Number of instances/tasks.
- Cluster VPC configuration.
- Subnets configuration.
- Configure security groups.
- Run the task.
- Go to the public IP address of cluster and you will be able to access your application.
Access Spring Boot Micro-services using Amazon API gateway.
- We need to deploy our application in elastic beanstalk.
- We need to configure endpoint of our application in API gateway.
- User sends request to API gateway which routes request to concern application as per configuration as hosted in elastic beanstalk.
- Build the below source and get jar.
- Go to AWS console and go to service elastic beanstalk.
- Create a new environment.
- Select environment tier as Web server environment.
- Give application name.
- Add runtime environment name.
- Add Domain.
- Add platform and version.
- Upload code choose the jar
- Click create environment.
- Using domain, you can access endpoints.
- But we need to access endpoints using API gateway and not elastic beanstalk.
- Go to API gateway service.
- Click on create API.
- Under REST, API click build.
- Choose Rest protocol.
- We can Create new API.
- Using new API.
- Cloning existing API.
- Import from swagger or open API3
- Example API.
- Select new API.
- Give API name.
- Give description.
- Endpoint type.
- Regional.
- Click create API.
- Next under resources specify all your end points, and HTTP method types.
- Create resource for root url.
- Under resource click actions to create a method.
- Select request type to method.
- Click on tick mark.
- Integration type as HTTP.
- Use http proxy integration.
- Specify endpoint URL.
- Click save.
- Similarly add for POST API.
- Click on action click on deploy API.
- Specify deployment stage.
- Stage name.
- Stage description.
- Click deploy.
- Now, you will see your stage
- Click on end point and you will get in work URL of your endpoint.
- The new URL is our API gateway URL.
No comments:
Post a Comment