From ba8b6824d1bf389b9e51541e289024d649802faa Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 19:39:05 +0530 Subject: [PATCH 01/37] Added script for CI Testing. --- tickets/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tickets/package.json b/tickets/package.json index f885d32..0b0a294 100644 --- a/tickets/package.json +++ b/tickets/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "start": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts", - "test": "jest --watchAll --no-cache" + "test": "jest --watchAll --no-cache", + "test:ci": "jest" }, "jest": { "preset": "ts-jest", From c460d4355bf258aacc39513f43e3799529b90aef Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 19:46:06 +0530 Subject: [PATCH 02/37] For Testing Auth CI Test. --- auth/src/routes/__test__/current-user.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/src/routes/__test__/current-user.test.ts b/auth/src/routes/__test__/current-user.test.ts index 0d478bc..474d2a0 100644 --- a/auth/src/routes/__test__/current-user.test.ts +++ b/auth/src/routes/__test__/current-user.test.ts @@ -11,7 +11,7 @@ it("Current-User Route Test: Check for Valid User Data Return - Returns current .get("/api/users/currentuser") .set("Cookie", cookieFromSignUp) .send() - .expect(200); + .expect(400); expect(response.body.currentUser.email).toEqual("tester@test.com"); }); From 0ccaf12dfda5a404018f2d540e5349c20b7748e2 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 19:48:13 +0530 Subject: [PATCH 03/37] Testing Success. --- auth/src/routes/__test__/current-user.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/src/routes/__test__/current-user.test.ts b/auth/src/routes/__test__/current-user.test.ts index 474d2a0..0d478bc 100644 --- a/auth/src/routes/__test__/current-user.test.ts +++ b/auth/src/routes/__test__/current-user.test.ts @@ -11,7 +11,7 @@ it("Current-User Route Test: Check for Valid User Data Return - Returns current .get("/api/users/currentuser") .set("Cookie", cookieFromSignUp) .send() - .expect(400); + .expect(200); expect(response.body.currentUser.email).toEqual("tester@test.com"); }); From 72e7a6144beaeb54166b32181bd0df26ff7ecba6 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 19:52:42 +0530 Subject: [PATCH 04/37] Updated Title. --- .github/workflows/CI - Tests - Auth Service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI - Tests - Auth Service.yml b/.github/workflows/CI - Tests - Auth Service.yml index c33ab5f..eee7459 100644 --- a/.github/workflows/CI - Tests - Auth Service.yml +++ b/.github/workflows/CI - Tests - Auth Service.yml @@ -1,4 +1,4 @@ -# ========================================= Main Branch ::: CI - Tests - Auth Service ========================================= +# ========================================= CI - Tests - Auth Service ========================================= name: CI - Tests - Auth Service From 1a333358e8d2f7cdf40ac7e50be78aa2bb634040 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 20:03:47 +0530 Subject: [PATCH 05/37] Configured CI Tests Workflow for Orders service. --- .github/workflows/CI - Tests - Orders Service.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/CI - Tests - Orders Service.yml diff --git a/.github/workflows/CI - Tests - Orders Service.yml b/.github/workflows/CI - Tests - Orders Service.yml new file mode 100644 index 0000000..3eec155 --- /dev/null +++ b/.github/workflows/CI - Tests - Orders Service.yml @@ -0,0 +1,13 @@ +# ========================================= CI - Tests - Orders Service ========================================= + +name: CI - Tests - Orders Service + +on: pull_request + +jobs: + Orders-Service-Pre-Integration-Tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: cd orders && npm install && npm run test:ci From ac886f3b6dc31ea1fac1fc67e242385e67dc36ca Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 20:04:31 +0530 Subject: [PATCH 06/37] Modified Job name. --- .github/workflows/CI - Tests - Auth Service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI - Tests - Auth Service.yml b/.github/workflows/CI - Tests - Auth Service.yml index eee7459..247f03d 100644 --- a/.github/workflows/CI - Tests - Auth Service.yml +++ b/.github/workflows/CI - Tests - Auth Service.yml @@ -5,7 +5,7 @@ name: CI - Tests - Auth Service on: pull_request jobs: - Production-Branch-Pre-Integration-Tests: + Auth-Service-Pre-Integration-Tests: runs-on: ubuntu-latest steps: From 30ea83861cc9214a086cb3cf5216ae3fdde5c1e9 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 20:06:29 +0530 Subject: [PATCH 07/37] Configured CI Tests Workflow for Payments service. --- .../workflows/CI - Tests - Orders Service copy.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/CI - Tests - Orders Service copy.yml diff --git a/.github/workflows/CI - Tests - Orders Service copy.yml b/.github/workflows/CI - Tests - Orders Service copy.yml new file mode 100644 index 0000000..dc07237 --- /dev/null +++ b/.github/workflows/CI - Tests - Orders Service copy.yml @@ -0,0 +1,13 @@ +# ========================================= CI - Tests - Payments Service ========================================= + +name: CI - Tests - Payments Service + +on: pull_request + +jobs: + Payments-Service-Pre-Integration-Tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: cd payments && npm install && npm run test:ci From 321c3418c22f5098050d1420010a6681888403bf Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 20:07:05 +0530 Subject: [PATCH 08/37] File name fixed. --- ... Orders Service copy.yml => CI - Tests - Payments Service.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{CI - Tests - Orders Service copy.yml => CI - Tests - Payments Service.yml} (100%) diff --git a/.github/workflows/CI - Tests - Orders Service copy.yml b/.github/workflows/CI - Tests - Payments Service.yml similarity index 100% rename from .github/workflows/CI - Tests - Orders Service copy.yml rename to .github/workflows/CI - Tests - Payments Service.yml From fb1a83f446ae967193153eead2f0073df564e508 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 20:08:42 +0530 Subject: [PATCH 09/37] Configured CI Tests Workflow for Tickets Service. --- .github/workflows/CI - Tests - Tickets Service.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/CI - Tests - Tickets Service.yml diff --git a/.github/workflows/CI - Tests - Tickets Service.yml b/.github/workflows/CI - Tests - Tickets Service.yml new file mode 100644 index 0000000..ccb2f83 --- /dev/null +++ b/.github/workflows/CI - Tests - Tickets Service.yml @@ -0,0 +1,13 @@ +# ========================================= CI - Tests - Tickets Service ========================================= + +name: CI - Tests - Tickets Service + +on: pull_request + +jobs: + Tickets-Service-Pre-Integration-Tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: cd tickets && npm install && npm run test:ci From 8d3233380c7eefe10f3b989eb2acf7cb50aff75b Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 22:43:30 +0530 Subject: [PATCH 10/37] Added configuration to run tests path specific. --- .github/workflows/CI - Tests - Auth Service.yml | 5 ++++- .github/workflows/CI - Tests - Orders Service.yml | 5 ++++- .github/workflows/CI - Tests - Payments Service.yml | 5 ++++- .github/workflows/CI - Tests - Tickets Service.yml | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI - Tests - Auth Service.yml b/.github/workflows/CI - Tests - Auth Service.yml index 247f03d..b51eb10 100644 --- a/.github/workflows/CI - Tests - Auth Service.yml +++ b/.github/workflows/CI - Tests - Auth Service.yml @@ -2,7 +2,10 @@ name: CI - Tests - Auth Service -on: pull_request +on: + pull_request: + paths: + - "auth/**" jobs: Auth-Service-Pre-Integration-Tests: diff --git a/.github/workflows/CI - Tests - Orders Service.yml b/.github/workflows/CI - Tests - Orders Service.yml index 3eec155..a36e407 100644 --- a/.github/workflows/CI - Tests - Orders Service.yml +++ b/.github/workflows/CI - Tests - Orders Service.yml @@ -2,7 +2,10 @@ name: CI - Tests - Orders Service -on: pull_request +on: + pull_request: + paths: + - "orders/**" jobs: Orders-Service-Pre-Integration-Tests: diff --git a/.github/workflows/CI - Tests - Payments Service.yml b/.github/workflows/CI - Tests - Payments Service.yml index dc07237..258438a 100644 --- a/.github/workflows/CI - Tests - Payments Service.yml +++ b/.github/workflows/CI - Tests - Payments Service.yml @@ -2,7 +2,10 @@ name: CI - Tests - Payments Service -on: pull_request +on: + pull_request: + paths: + - "payments/**" jobs: Payments-Service-Pre-Integration-Tests: diff --git a/.github/workflows/CI - Tests - Tickets Service.yml b/.github/workflows/CI - Tests - Tickets Service.yml index ccb2f83..2d8fb29 100644 --- a/.github/workflows/CI - Tests - Tickets Service.yml +++ b/.github/workflows/CI - Tests - Tickets Service.yml @@ -2,7 +2,10 @@ name: CI - Tests - Tickets Service -on: pull_request +on: + pull_request: + paths: + - "tickets/**" jobs: Tickets-Service-Pre-Integration-Tests: From 7bb6322bf5f377867e0a6a82169c891f3e5799e7 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 22:47:51 +0530 Subject: [PATCH 11/37] Made a change to check Test Status. --- orders/src/routes/__test__/delete.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orders/src/routes/__test__/delete.test.ts b/orders/src/routes/__test__/delete.test.ts index 42acd6e..bbdcf93 100644 --- a/orders/src/routes/__test__/delete.test.ts +++ b/orders/src/routes/__test__/delete.test.ts @@ -12,7 +12,7 @@ const mockOrderId = new mongoose.Types.ObjectId().toHexString(); it("Orders DELETE Route Test: Has a route handler listening to /api/orders/:orderId for DELETE Requests.", async () => { // Make a request to the route and make sure that we are not getting a 404 which indicates the absence of the route const response = await request(app).delete(`/api/orders/${mockOrderId}`); - expect(response.status).not.toEqual(404); + expect(response.status).not.toEqual(400); }); it("Orders DELETE Route Test: /api/orders/:orderId can only be accessed only if the user is Signed-In.", async () => { From e2d822fef9ebcd60483b7deb176bad21b179c911 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 22:51:47 +0530 Subject: [PATCH 12/37] Updated test condition. --- orders/src/routes/__test__/delete.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/orders/src/routes/__test__/delete.test.ts b/orders/src/routes/__test__/delete.test.ts index bbdcf93..3b62f69 100644 --- a/orders/src/routes/__test__/delete.test.ts +++ b/orders/src/routes/__test__/delete.test.ts @@ -12,12 +12,12 @@ const mockOrderId = new mongoose.Types.ObjectId().toHexString(); it("Orders DELETE Route Test: Has a route handler listening to /api/orders/:orderId for DELETE Requests.", async () => { // Make a request to the route and make sure that we are not getting a 404 which indicates the absence of the route const response = await request(app).delete(`/api/orders/${mockOrderId}`); - expect(response.status).not.toEqual(400); + expect(response.status).not.toEqual(404); }); it("Orders DELETE Route Test: /api/orders/:orderId can only be accessed only if the user is Signed-In.", async () => { // Make a request to the route without any authentication data and expect a 401 - not authenticated - await request(app).delete(`/api/orders/${mockOrderId}`).expect(401); + await request(app).delete(`/api/orders/${mockOrderId}`).expect(404); }); it("Orders DELETE Route Test: /api/orders/:orderId can be accessed if the user is Signed-In.", async () => { From cf1daac1580be261fd35205374d6e47aefd4abc0 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sat, 28 Oct 2023 22:53:45 +0530 Subject: [PATCH 13/37] Test Performing as Expected - Reverting change. --- orders/src/routes/__test__/delete.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orders/src/routes/__test__/delete.test.ts b/orders/src/routes/__test__/delete.test.ts index 3b62f69..42acd6e 100644 --- a/orders/src/routes/__test__/delete.test.ts +++ b/orders/src/routes/__test__/delete.test.ts @@ -17,7 +17,7 @@ it("Orders DELETE Route Test: Has a route handler listening to /api/orders/:orde it("Orders DELETE Route Test: /api/orders/:orderId can only be accessed only if the user is Signed-In.", async () => { // Make a request to the route without any authentication data and expect a 401 - not authenticated - await request(app).delete(`/api/orders/${mockOrderId}`).expect(404); + await request(app).delete(`/api/orders/${mockOrderId}`).expect(401); }); it("Orders DELETE Route Test: /api/orders/:orderId can be accessed if the user is Signed-In.", async () => { From 65625215716b192cb067af6a2ceadf196265ab4f Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 00:08:52 +0530 Subject: [PATCH 14/37] Added CD config file for Auth Service. --- .../workflows/CD - Deploy - Auth Service.yml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/CD - Deploy - Auth Service.yml diff --git a/.github/workflows/CD - Deploy - Auth Service.yml b/.github/workflows/CD - Deploy - Auth Service.yml new file mode 100644 index 0000000..078b6ac --- /dev/null +++ b/.github/workflows/CD - Deploy - Auth Service.yml @@ -0,0 +1,23 @@ +# ========================================= CD - Deploy - Auth Service ========================================= + +name: CD - Deploy - Auth Service + +on: + push: + branches: + - production + paths: + - "auth/**" + +jobs: + Auth-Service-CD-Pipeline: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: cd auth && docker build -t alwinsimon/auth . + - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - run: docker push alwinsimon/auth From 58f6e742774e46741ba9f9d613938f1602fc5700 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 00:20:55 +0530 Subject: [PATCH 15/37] Made a change to test Auth CD Workflow. --- auth/src/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/auth/src/index.ts b/auth/src/index.ts index 254f16a..c5fc846 100644 --- a/auth/src/index.ts +++ b/auth/src/index.ts @@ -3,6 +3,8 @@ import mongoose from "mongoose"; import { app } from "./app"; const startServer = async () => { + + console.log("Starting up......."); const PORT = 3000; const SERVICE_NAME = "AUTH"; From 4bdf8c802d7b15c5f8896632dd299ba90f56dd05 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 00:31:08 +0530 Subject: [PATCH 16/37] Minor fix in docker repository name. --- .github/workflows/CD - Deploy - Auth Service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CD - Deploy - Auth Service.yml b/.github/workflows/CD - Deploy - Auth Service.yml index 078b6ac..60b1e65 100644 --- a/.github/workflows/CD - Deploy - Auth Service.yml +++ b/.github/workflows/CD - Deploy - Auth Service.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@v3 - - run: cd auth && docker build -t alwinsimon/auth . + - run: cd auth && docker build -t alwinsimon/bookmyseat-auth . - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} From ab650ad61c9ccdd34a29c38645851dce3035f6ba Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 00:32:42 +0530 Subject: [PATCH 17/37] Reverted change made for testing. --- auth/src/index.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/auth/src/index.ts b/auth/src/index.ts index c5fc846..6bcdcef 100644 --- a/auth/src/index.ts +++ b/auth/src/index.ts @@ -3,9 +3,6 @@ import mongoose from "mongoose"; import { app } from "./app"; const startServer = async () => { - - console.log("Starting up......."); - const PORT = 3000; const SERVICE_NAME = "AUTH"; From 41e9e384eaa193e0213e66aff9854bd771a9e157 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 00:44:24 +0530 Subject: [PATCH 18/37] Updated image name in docker push. --- .github/workflows/CD - Deploy - Auth Service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CD - Deploy - Auth Service.yml b/.github/workflows/CD - Deploy - Auth Service.yml index 60b1e65..8463314 100644 --- a/.github/workflows/CD - Deploy - Auth Service.yml +++ b/.github/workflows/CD - Deploy - Auth Service.yml @@ -20,4 +20,4 @@ jobs: env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - - run: docker push alwinsimon/auth + - run: docker push alwinsimon/bookmyseat-auth From 3721ae9b87c49a3c07a19023b7606a03f0c1eebe Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 00:48:12 +0530 Subject: [PATCH 19/37] Making a change to trigger CD workflow. --- auth/src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/auth/src/index.ts b/auth/src/index.ts index 6bcdcef..c5fc846 100644 --- a/auth/src/index.ts +++ b/auth/src/index.ts @@ -3,6 +3,9 @@ import mongoose from "mongoose"; import { app } from "./app"; const startServer = async () => { + + console.log("Starting up......."); + const PORT = 3000; const SERVICE_NAME = "AUTH"; From 8999048ff95f6b41306b9c3d0d55f1ea761d8735 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 00:53:49 +0530 Subject: [PATCH 20/37] Reverted Change. --- auth/src/index.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/auth/src/index.ts b/auth/src/index.ts index c5fc846..6bcdcef 100644 --- a/auth/src/index.ts +++ b/auth/src/index.ts @@ -3,9 +3,6 @@ import mongoose from "mongoose"; import { app } from "./app"; const startServer = async () => { - - console.log("Starting up......."); - const PORT = 3000; const SERVICE_NAME = "AUTH"; From f8bdf61a18a234cee975df5b57fcfaf2d6e2b152 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 10:05:18 +0530 Subject: [PATCH 21/37] Added K8s config for CD Auth Deployment restart. --- .github/workflows/CD - Deploy - Auth Service.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/CD - Deploy - Auth Service.yml b/.github/workflows/CD - Deploy - Auth Service.yml index 8463314..d21e01d 100644 --- a/.github/workflows/CD - Deploy - Auth Service.yml +++ b/.github/workflows/CD - Deploy - Auth Service.yml @@ -21,3 +21,8 @@ jobs: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - run: docker push alwinsimon/bookmyseat-auth + - uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - run: doctl kubernetes cluster kubeconfig save bookmyseat-k8s + - run: kubectl rollout restart deployment auth-depl From c2906aa3312ce836a419f91d80f3b56c00ab47aa Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 10:10:21 +0530 Subject: [PATCH 22/37] Added Deploy Manifest Config to apply all config inside infra/k8 directory to the cluster. --- .github/workflows/CD - Deploy - Manifests.yml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/CD - Deploy - Manifests.yml diff --git a/.github/workflows/CD - Deploy - Manifests.yml b/.github/workflows/CD - Deploy - Manifests.yml new file mode 100644 index 0000000..0548316 --- /dev/null +++ b/.github/workflows/CD - Deploy - Manifests.yml @@ -0,0 +1,22 @@ +# ========================================= CD - Deploy - Manifests ========================================= + +name: CD - Deploy - Manifests + +on: + push: + branches: + - production + paths: + - "infra/**" + +jobs: + Deploy-Manifests-CD-Pipeline: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - run: doctl kubernetes cluster kubeconfig save bookmyseat-k8s + - run: kubectl apply -f infra/k8s From c81d215b6a94d8d4ae07868d81a3f36d6fcde594 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 10:18:53 +0530 Subject: [PATCH 23/37] Restructured Infra Directory to make use of different Ingress config for development and production environments. --- infra/{k8s => k8s-dev}/ingress-srv.yaml | 0 infra/k8s-prod/ingress-srv.yaml | 47 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+) rename infra/{k8s => k8s-dev}/ingress-srv.yaml (100%) create mode 100644 infra/k8s-prod/ingress-srv.yaml diff --git a/infra/k8s/ingress-srv.yaml b/infra/k8s-dev/ingress-srv.yaml similarity index 100% rename from infra/k8s/ingress-srv.yaml rename to infra/k8s-dev/ingress-srv.yaml diff --git a/infra/k8s-prod/ingress-srv.yaml b/infra/k8s-prod/ingress-srv.yaml new file mode 100644 index 0000000..3defdde --- /dev/null +++ b/infra/k8s-prod/ingress-srv.yaml @@ -0,0 +1,47 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ingress-service + annotations: + kubernetes.io/ingress.class: nginx + nginx.ingress.kubernetes.io/use-regex: "true" +spec: + rules: + - host: bookmyseat.dev + http: + paths: + - path: /api/users/?(.*) + pathType: Prefix + backend: + service: + name: auth-srv + port: + number: 3000 + - path: /api/tickets/?(.*) + pathType: Prefix + backend: + service: + name: tickets-srv + port: + number: 3000 + - path: /api/orders/?(.*) + pathType: Prefix + backend: + service: + name: orders-srv + port: + number: 3000 + - path: /api/payments/?(.*) + pathType: Prefix + backend: + service: + name: payments-srv + port: + number: 3000 + - path: /?(.*) + pathType: Prefix + backend: + service: + name: client-srv + port: + number: 3000 From bd2c928f2728e9767c075b965bf8c56f95b52238 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 10:21:28 +0530 Subject: [PATCH 24/37] Configured Skaffold to apply development ingress config file. --- skaffold.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/skaffold.yaml b/skaffold.yaml index ef60155..4c6dab9 100644 --- a/skaffold.yaml +++ b/skaffold.yaml @@ -4,6 +4,7 @@ deploy: kubectl: manifests: - ./infra/k8s/* + - ./infra/k8s-dev/* build: local: push: true From c533c0b387efa899d7dd710e1eb5a8f01b541655 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 10:27:52 +0530 Subject: [PATCH 25/37] Modified to apply production configuration file for ingress. --- .github/workflows/CD - Deploy - Manifests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CD - Deploy - Manifests.yml b/.github/workflows/CD - Deploy - Manifests.yml index 0548316..fd86cc4 100644 --- a/.github/workflows/CD - Deploy - Manifests.yml +++ b/.github/workflows/CD - Deploy - Manifests.yml @@ -19,4 +19,4 @@ jobs: with: token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} - run: doctl kubernetes cluster kubeconfig save bookmyseat-k8s - - run: kubectl apply -f infra/k8s + - run: kubectl apply -f infra/k8s && kubectl apply -f infra/k8s-prod From 7ce2d19cfc9609dea584eea05e085e1ebeb905cb Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 11:55:49 +0530 Subject: [PATCH 26/37] Added comments for better understanding. --- .github/workflows/CD - Deploy - Auth Service.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CD - Deploy - Auth Service.yml b/.github/workflows/CD - Deploy - Auth Service.yml index d21e01d..8866926 100644 --- a/.github/workflows/CD - Deploy - Auth Service.yml +++ b/.github/workflows/CD - Deploy - Auth Service.yml @@ -14,13 +14,16 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 + # Build Image and push to Docker registry - run: cd auth && docker build -t alwinsimon/bookmyseat-auth . - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - run: docker push alwinsimon/bookmyseat-auth + + # Restart Deployment in K8s cluster deployed in Digital Ocean - uses: digitalocean/action-doctl@v2 with: token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} From 706ef6fc2eac9c73acc1c378d55424e07b6c9593 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 12:39:48 +0530 Subject: [PATCH 27/37] Replaced Hardcoded cluster name in the config with cluster Id pulled from github secrets. --- .github/workflows/CD - Deploy - Auth Service.yml | 2 +- .github/workflows/CD - Deploy - Manifests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CD - Deploy - Auth Service.yml b/.github/workflows/CD - Deploy - Auth Service.yml index 8866926..81c158f 100644 --- a/.github/workflows/CD - Deploy - Auth Service.yml +++ b/.github/workflows/CD - Deploy - Auth Service.yml @@ -27,5 +27,5 @@ jobs: - uses: digitalocean/action-doctl@v2 with: token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} - - run: doctl kubernetes cluster kubeconfig save bookmyseat-k8s + - run: doctl kubernetes cluster kubeconfig save ${{ secrets.DIGITALOCEAN_CLUSTER_ID }} - run: kubectl rollout restart deployment auth-depl diff --git a/.github/workflows/CD - Deploy - Manifests.yml b/.github/workflows/CD - Deploy - Manifests.yml index fd86cc4..d3af011 100644 --- a/.github/workflows/CD - Deploy - Manifests.yml +++ b/.github/workflows/CD - Deploy - Manifests.yml @@ -18,5 +18,5 @@ jobs: - uses: digitalocean/action-doctl@v2 with: token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} - - run: doctl kubernetes cluster kubeconfig save bookmyseat-k8s + - run: doctl kubernetes cluster kubeconfig save ${{ secrets.DIGITALOCEAN_CLUSTER_ID }} - run: kubectl apply -f infra/k8s && kubectl apply -f infra/k8s-prod From afd5ed39d7877a238b0bf0b2a5117d66adbf689f Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 13:30:43 +0530 Subject: [PATCH 28/37] Added a comment for testing CD trigger. --- auth/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/auth/src/index.ts b/auth/src/index.ts index 6bcdcef..43011d7 100644 --- a/auth/src/index.ts +++ b/auth/src/index.ts @@ -3,6 +3,7 @@ import mongoose from "mongoose"; import { app } from "./app"; const startServer = async () => { + console.log("Starting up ......."); const PORT = 3000; const SERVICE_NAME = "AUTH"; From d4ef9e7c9d85dab045f38d709e0d85835e2bcafe Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 13:39:54 +0530 Subject: [PATCH 29/37] Reverted change made for testing. --- auth/src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/auth/src/index.ts b/auth/src/index.ts index 43011d7..6bcdcef 100644 --- a/auth/src/index.ts +++ b/auth/src/index.ts @@ -3,7 +3,6 @@ import mongoose from "mongoose"; import { app } from "./app"; const startServer = async () => { - console.log("Starting up ......."); const PORT = 3000; const SERVICE_NAME = "AUTH"; From d27899f5bc8f608c1449bcc649845c3e24fc9148 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 13:50:03 +0530 Subject: [PATCH 30/37] Configured CD for Client Service. --- .../CD - Deploy - Client Service.yml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/CD - Deploy - Client Service.yml diff --git a/.github/workflows/CD - Deploy - Client Service.yml b/.github/workflows/CD - Deploy - Client Service.yml new file mode 100644 index 0000000..3cc0897 --- /dev/null +++ b/.github/workflows/CD - Deploy - Client Service.yml @@ -0,0 +1,31 @@ +# ========================================= CD - Deploy - Client Service ========================================= + +name: CD - Deploy - Client Service + +on: + push: + branches: + - production + paths: + - "client/**" + +jobs: + Client-Service-CD-Pipeline: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + # Build Image and push to Docker registry + - run: cd client && docker build -t alwinsimon/bookmyseat-client . + - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - run: docker push alwinsimon/bookmyseat-client + + # Restart Deployment in K8s cluster deployed in Digital Ocean + - uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - run: doctl kubernetes cluster kubeconfig save ${{ secrets.DIGITALOCEAN_CLUSTER_ID }} + - run: kubectl rollout restart deployment client-depl From 2ee4c81c9fc79f7d75678a4a61ffca76fc3e6fc9 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 13:52:43 +0530 Subject: [PATCH 31/37] Configured CD for Expiration Service. --- .../CD - Deploy - Expiration Service.yml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/CD - Deploy - Expiration Service.yml diff --git a/.github/workflows/CD - Deploy - Expiration Service.yml b/.github/workflows/CD - Deploy - Expiration Service.yml new file mode 100644 index 0000000..93dd187 --- /dev/null +++ b/.github/workflows/CD - Deploy - Expiration Service.yml @@ -0,0 +1,31 @@ +# ========================================= CD - Deploy - Expiration Service ========================================= + +name: CD - Deploy - Expiration Service + +on: + push: + branches: + - production + paths: + - "expiration/**" + +jobs: + Expiration-Service-CD-Pipeline: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + # Build Image and push to Docker registry + - run: cd expiration && docker build -t alwinsimon/bookmyseat-expiration . + - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - run: docker push alwinsimon/bookmyseat-expiration + + # Restart Deployment in K8s cluster deployed in Digital Ocean + - uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - run: doctl kubernetes cluster kubeconfig save ${{ secrets.DIGITALOCEAN_CLUSTER_ID }} + - run: kubectl rollout restart deployment expiration-depl From 26bd96caa2f043b086c9a39d5f04b95ef70f6b6a Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 13:54:50 +0530 Subject: [PATCH 32/37] Configured CD for Orders Service. --- .../CD - Deploy - Orders Service.yml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/CD - Deploy - Orders Service.yml diff --git a/.github/workflows/CD - Deploy - Orders Service.yml b/.github/workflows/CD - Deploy - Orders Service.yml new file mode 100644 index 0000000..04dd690 --- /dev/null +++ b/.github/workflows/CD - Deploy - Orders Service.yml @@ -0,0 +1,31 @@ +# ========================================= CD - Deploy - Orders Service ========================================= + +name: CD - Deploy - Orders Service + +on: + push: + branches: + - production + paths: + - "orders/**" + +jobs: + Orders-Service-CD-Pipeline: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + # Build Image and push to Docker registry + - run: cd orders && docker build -t alwinsimon/bookmyseat-orders . + - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - run: docker push alwinsimon/bookmyseat-orders + + # Restart Deployment in K8s cluster deployed in Digital Ocean + - uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - run: doctl kubernetes cluster kubeconfig save ${{ secrets.DIGITALOCEAN_CLUSTER_ID }} + - run: kubectl rollout restart deployment orders-depl From 81b38bd2f6e20ff746e04081939d02eb1fd009e1 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 13:56:20 +0530 Subject: [PATCH 33/37] Configured CD for Payments Service. --- .../CD - Deploy - Payments Service.yml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/CD - Deploy - Payments Service.yml diff --git a/.github/workflows/CD - Deploy - Payments Service.yml b/.github/workflows/CD - Deploy - Payments Service.yml new file mode 100644 index 0000000..65be0c7 --- /dev/null +++ b/.github/workflows/CD - Deploy - Payments Service.yml @@ -0,0 +1,31 @@ +# ========================================= CD - Deploy - Payments Service ========================================= + +name: CD - Deploy - Payments Service + +on: + push: + branches: + - production + paths: + - "payments/**" + +jobs: + Payments-Service-CD-Pipeline: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + # Build Image and push to Docker registry + - run: cd payments && docker build -t alwinsimon/bookmyseat-payments . + - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - run: docker push alwinsimon/bookmyseat-payments + + # Restart Deployment in K8s cluster deployed in Digital Ocean + - uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - run: doctl kubernetes cluster kubeconfig save ${{ secrets.DIGITALOCEAN_CLUSTER_ID }} + - run: kubectl rollout restart deployment payments-depl From 4aee11b12a71564a265ca098cfc134ca75b5d2f5 Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 13:57:44 +0530 Subject: [PATCH 34/37] Configured CD for Tickets Service. --- .../CD - Deploy - Tickets Service.yml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/CD - Deploy - Tickets Service.yml diff --git a/.github/workflows/CD - Deploy - Tickets Service.yml b/.github/workflows/CD - Deploy - Tickets Service.yml new file mode 100644 index 0000000..d54ba7d --- /dev/null +++ b/.github/workflows/CD - Deploy - Tickets Service.yml @@ -0,0 +1,31 @@ +# ========================================= CD - Deploy - Tickets Service ========================================= + +name: CD - Deploy - Tickets Service + +on: + push: + branches: + - production + paths: + - "tickets/**" + +jobs: + Tickets-Service-CD-Pipeline: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + # Build Image and push to Docker registry + - run: cd tickets && docker build -t alwinsimon/bookmyseat-tickets . + - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - run: docker push alwinsimon/bookmyseat-tickets + + # Restart Deployment in K8s cluster deployed in Digital Ocean + - uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - run: doctl kubernetes cluster kubeconfig save ${{ secrets.DIGITALOCEAN_CLUSTER_ID }} + - run: kubectl rollout restart deployment tickets-depl From 6c4316b5ae71503bc89823b9c15b742337213ffa Mon Sep 17 00:00:00 2001 From: "Dr. Alwin Simon" <003alwin@gmail.com> Date: Sun, 29 Oct 2023 14:13:07 +0530 Subject: [PATCH 35/37] Made small changes to TEST CI-CD. --- auth/src/index.ts | 1 + client/pages/index.js | 2 +- expiration/src/index.ts | 1 + orders/src/index.ts | 1 + payments/src/index.ts | 1 + tickets/src/index.ts | 1 + 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/auth/src/index.ts b/auth/src/index.ts index 6bcdcef..35dce16 100644 --- a/auth/src/index.ts +++ b/auth/src/index.ts @@ -3,6 +3,7 @@ import mongoose from "mongoose"; import { app } from "./app"; const startServer = async () => { + console.log("Starting up............"); const PORT = 3000; const SERVICE_NAME = "AUTH"; diff --git a/client/pages/index.js b/client/pages/index.js index 2401514..2023e0a 100644 --- a/client/pages/index.js +++ b/client/pages/index.js @@ -6,7 +6,7 @@ const IndexPage = ({ currentUser, tickets }) => { <>