|
| 1 | +## ECS Test CASE |
| 2 | + |
| 3 | +ECS clustter is deployed with following process: |
| 4 | +- build Docker Image |
| 5 | +- upload to Docker hub or ECR |
| 6 | +- update docker-compose file |
| 7 | +- create and use docker context |
| 8 | +- deploy application |
| 9 | + |
| 10 | +### If want to install Chronos as dependency (optional) |
| 11 | + |
| 12 | +1: add a `.env` file to the *server* folder that contains the following key/value pairs: |
| 13 | +- `CHRONOS_DB`: `MongoDB` or `PostgreSQL` |
| 14 | +- `CHRONOS_URI`: The URI to the desired MongoDB or PostgreSQL database to save health metrics via **Chronos** |
| 15 | + |
| 16 | +2: Then look at the `package.json` file in the server folder and note how `@chronosmicro/tracker` is included as a dependency: |
| 17 | +- If the @chronosmicro/tracker dependency is listed as a remote npm package (i.e. `"@chronosmicro/tracker": "^8.0.1"`), no further work is needed. |
| 18 | + |
| 19 | +- If the @chronosmicro/tracker dependency is listed as a local npm package (i.e. `"@chronosmicro/tracker": "file:./chronos_npm_package"`), the Docker build will require that the the Chronos code is in this folder. Copy the _chronos_npm_package_ folder in manually. |
| 20 | + |
| 21 | +### Deploy application in ECS |
| 22 | + |
| 23 | +Step 1: build Docker Image |
| 24 | +``` |
| 25 | +docker build -t ecs-test:1.0 . |
| 26 | +``` |
| 27 | +* If you want to change name and/or tag of docker image, please make sure to update docker-compose.yaml file accordingly. And do Not miss the . at the end as it denotes location of the Dockerfile |
| 28 | + |
| 29 | +Step 2: docker-compose to test out image (image is stored locally right now) |
| 30 | +``` |
| 31 | + docker-compose -f docker-compose.yaml up |
| 32 | +``` |
| 33 | +Step 3: Upload image to docker hub or ECR, update docker-compose.yaml with new URI of image |
| 34 | +- you only need to update the image for ecs-test, mongo and mongo-express are pulled from docker public library |
| 35 | + |
| 36 | +Step 4: Set up AWS account, grant access to floowing AWS IAM permissions listed [here](https://docs.docker.com/cloud/ecs-integration/#requirements). Some other permissions you would need includes: |
| 37 | +* iam:DeleteRolePolicy |
| 38 | +* iam:PutRolePolicy |
| 39 | +* ecr:GetAuthorizationToken |
| 40 | +* logs:TagResource |
| 41 | +* elasticfilesystem:CreateFileSystem |
| 42 | + |
| 43 | +If you push docker image in ECR you might need additional permission as well. |
| 44 | + |
| 45 | +Step 5: Generate access key in IAM -> Users -> yourusername -> secureity credentials -> Access Keys. _Make sure you save your secret access key as it is only accessible once when generated._ |
| 46 | + |
| 47 | +Step 6: Create and use AWS context, follow instruction [here](https://docs.docker.com/cloud/ecs-integration/#requirements). |
| 48 | + |
| 49 | +Step 7: Deploy test application in ECS |
| 50 | +``` |
| 51 | + docker compose up |
| 52 | +``` |
| 53 | +### some notes about the ecs-test |
| 54 | + |
| 55 | +The way deployment set up is using Fargate, you will not be able to see graph in cluster->metrics. Instead, check inside services or cloudwatch. The ultimate visulization is in Chronos!!! |
0 commit comments