From 713ea5a88d8beb0713b8e8a2c1aaa238b4b3b190 Mon Sep 17 00:00:00 2001 From: Brusk Hamarash Date: Sun, 6 Mar 2022 15:56:18 +0300 Subject: [PATCH 1/6] Adds microservices checklist (WIP) --- .../09-Checklist For Microservices.md | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md diff --git a/docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md b/docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md new file mode 100644 index 0000000..d9c6177 --- /dev/null +++ b/docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md @@ -0,0 +1,77 @@ +# Checklist for Microservices + +Use the following checklist when dealing with a microservices architecture internally with DIT. This guide is intended for use among DIT software developers. + +| ID | Name | Description | +| ------ | ---------------------------------------------- | ------------------------------------------------------------ | +| SMR-1 | Authentication | Check the presence of these two parameters in the request headers:
* X-Auth-User
* X-Auth-Signature

Verify the signature in X-Auth-Signature with a given public key. | +| SMR-2 | Database per service pattern | Separate your microservice's database from the rest of the services. | +| SMR-3 | Events: Use Cloud Native Events | Use Cloud Native Events envelope format to publish messages to the message broker.
For the data property, use JSONAPI Specs (see SMR-9). | +| SMR-4 | Events: Idempotent Consumers | Make your consumers idempotent by processing messages with the same event id once. | +| SMR-5 | Events: Transactional Outbox | Make publishing of events atomic along with operation applied on the corresponding resource. | +| SMR-6 | Events: Polling Publisher Pattern | Have a worker that uses polling to read unpublished messages and push them to the message broker | +| SMR-7 | Events: Single Exchange, Multiple Routing Keys | Use a single exchange to publish message to a message broker, but utilize routing keys. | +| SMR-8 | Events: Follow Naming Conventions | Use the following convention to name your routing keys: Annex 1.1
Use the followiing convetnions to name your queues: Annex 1.2 | +| SMR-9 | REST: Adopt JSON API Specs | Fully adopt the JSONAPI Specs for responses.
| +| SMR-10 | REST: JSONAPI Pagination Extension | Use the following JSONAPI extension for pagination in responses: See Annex 2 | +| SMR-11 | REST: JSONAPI Request Extension | Use the following JSONAPI extension for requests: Annex 3 | +| SMR-12 | REST: Async Request Reply Pattern | Use the Asynchronous Request Reply Pattern when dealing with computationally-intesive tasks that spans multiple microservices. See Annex 4.
The proper HTTP Code for this response is 202 ACCEPTED | +| SMR-13 | REST: Use Camel Case for JSONAPI Member Names | Use Camel Case for naming members in JSONAPI specs. | +| SMR-14 | REST: Use Idempotency Key | For POST, DELETE and PATCH requests, require header Idempotency-Key to be present. Process requests with the same idempotency key only once. | +| SMR-15 | Use Open API for REST Documentation | Use Open API >= 3 to document REST endpoint | +| SMR-16 | Use AsyncAPI For Events Documentation | Use AsyncAPI >= 2 to document Events. | + + + + +## Annexes + +### Annex 1 + +1. [api name]-api.[resource name in plural form].[operation type in past tense] + Example: *users-api.users.created +2. [api name]-api.[routing key of the listenting queue] + Example: orders-api.users-api.users.created + +### Annex 2 + +```JSON +{ + meta: { + page: { + totalPage: "integer" + count: "integer", + limitValue: "integer", + currentPage: "integer" + } + } +} +``` + + + +### Annex 3 + +```json +{ + data: {...request_payload} +} +``` + + + +### Annex 4 + +```JSON +{ + data: { + id: "string", + type: "async_request_responses", + attributes: { + retryAt: "string(datetime)", + location: "string" + } + } +} +``` + From bde782c1ed920872c0da40239c35c9ab8884e3fa Mon Sep 17 00:00:00 2001 From: Brusk Hamarash Date: Tue, 5 Apr 2022 10:55:47 +0300 Subject: [PATCH 2/6] Fixes typo --- .../09-Checklist For Microservices.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md b/docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md index d9c6177..e75496c 100644 --- a/docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md +++ b/docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md @@ -39,7 +39,7 @@ Use the following checklist when dealing with a microservices architecture inter { meta: { page: { - totalPage: "integer" + totalPages: "integer" count: "integer", limitValue: "integer", currentPage: "integer" From 96ec516c85fa499a7ff7d40e24e48f0b94f67a03 Mon Sep 17 00:00:00 2001 From: Brusk Hamarash Date: Tue, 5 Apr 2022 15:31:37 +0300 Subject: [PATCH 3/6] Adds pagination start number --- .../09-Checklist For Microservices.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md b/docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md index e75496c..8d824f4 100644 --- a/docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md +++ b/docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md @@ -20,6 +20,7 @@ Use the following checklist when dealing with a microservices architecture inter | SMR-14 | REST: Use Idempotency Key | For POST, DELETE and PATCH requests, require header Idempotency-Key to be present. Process requests with the same idempotency key only once. | | SMR-15 | Use Open API for REST Documentation | Use Open API >= 3 to document REST endpoint | | SMR-16 | Use AsyncAPI For Events Documentation | Use AsyncAPI >= 2 to document Events. | +| SMR-17 | Pagination must start from 1, not 0 | Pagination must start from page 1. This means that at Page 1, the offset is 0. | From c52bbc4d6945a2f6c01edd606216ef9901034e3b Mon Sep 17 00:00:00 2001 From: Brusk Hamarash Date: Thu, 7 Apr 2022 10:36:19 +0300 Subject: [PATCH 4/6] Use Kebab-case for endpoint names --- .../09-Checklist For Microservices.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md b/docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md index 8d824f4..781bfff 100644 --- a/docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md +++ b/docs/Software Development/04-Software Application Specifications/09-Checklist For Microservices.md @@ -18,9 +18,10 @@ Use the following checklist when dealing with a microservices architecture inter | SMR-12 | REST: Async Request Reply Pattern | Use the Asynchronous Request Reply Pattern when dealing with computationally-intesive tasks that spans multiple microservices. See Annex 4.
The proper HTTP Code for this response is 202 ACCEPTED | | SMR-13 | REST: Use Camel Case for JSONAPI Member Names | Use Camel Case for naming members in JSONAPI specs. | | SMR-14 | REST: Use Idempotency Key | For POST, DELETE and PATCH requests, require header Idempotency-Key to be present. Process requests with the same idempotency key only once. | -| SMR-15 | Use Open API for REST Documentation | Use Open API >= 3 to document REST endpoint | -| SMR-16 | Use AsyncAPI For Events Documentation | Use AsyncAPI >= 2 to document Events. | -| SMR-17 | Pagination must start from 1, not 0 | Pagination must start from page 1. This means that at Page 1, the offset is 0. | +| SMR-15 | REST: Use Kebab-case for endpoint names | Use Kebab-case to name your REST endpoints. | +| SMR-16 | Use Open API for REST Documentation | Use Open API >= 3 to document REST endpoint | +| SMR-17 | Use AsyncAPI For Events Documentation | Use AsyncAPI >= 2 to document Events. | +| SMR-18 | Pagination must start from 1, not 0 | Pagination must start from page 1. This means that at Page 1, the offset is 0. | From ea139719cd123c75563e2ed4534b8dd60b5e2fce Mon Sep 17 00:00:00 2001 From: "Shkar T. Noori" Date: Thu, 7 Apr 2022 07:57:53 +0000 Subject: [PATCH 5/6] Use alpine nginx and fix issue with port --- .dockerignore | 1 - Dockerfile | 4 ++-- kubernetes/base/deployment.yaml | 2 +- kubernetes/base/service.yaml | 1 - 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index 2a800ff..83b2d44 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,7 +4,6 @@ .dockerignore .gitignore .docusaurus -build README.md Dockerfile kubernetes diff --git a/Dockerfile b/Dockerfile index 2e74ddf..71a9664 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ COPY *.js ./ RUN npm run build -FROM nginxinc/nginx-unprivileged:1.20-alpine AS production +FROM nginx:stable-alpine AS production COPY --from=build-stage /app/build /usr/share/nginx/html -EXPOSE 8080 +EXPOSE 80 diff --git a/kubernetes/base/deployment.yaml b/kubernetes/base/deployment.yaml index 24cf952..7e4f282 100644 --- a/kubernetes/base/deployment.yaml +++ b/kubernetes/base/deployment.yaml @@ -35,7 +35,7 @@ spec: cpu: 5m ports: - name: http - containerPort: 8080 + containerPort: 80 livenessProbe: tcpSocket: diff --git a/kubernetes/base/service.yaml b/kubernetes/base/service.yaml index db5a10e..54983f3 100644 --- a/kubernetes/base/service.yaml +++ b/kubernetes/base/service.yaml @@ -10,5 +10,4 @@ spec: app: dsm-client ports: - port: 80 - targetPort: 8080 type: ClusterIP From 56623d576789d176bc1092384a1782fcb79092a4 Mon Sep 17 00:00:00 2001 From: "Shkar T. Noori" Date: Thu, 7 Apr 2022 08:10:01 +0000 Subject: [PATCH 6/6] Remove security context --- kubernetes/base/deployment.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/kubernetes/base/deployment.yaml b/kubernetes/base/deployment.yaml index 7e4f282..4f643af 100644 --- a/kubernetes/base/deployment.yaml +++ b/kubernetes/base/deployment.yaml @@ -17,12 +17,6 @@ spec: app: dsm-client spec: - securityContext: - fsGroup: 101 - runAsUser: 101 - runAsGroup: 101 - runAsNonRoot: true - containers: - name: dsm-client image: IMAGE