From d08454a00fea51154114a624f67845c362b2899d Mon Sep 17 00:00:00 2001 From: simbayippy Date: Tue, 8 Oct 2024 17:27:21 +0800 Subject: [PATCH 01/25] init for cd --- .github/workflows/deploy.yml | 23 +++++++++++++++++++ cloudbuild.yaml | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 cloudbuild.yaml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000000..d85890a3eb --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,23 @@ +name: Deploy to GCP + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v0 + with: + project_id: ${{ secrets.GCP_PROJECT_ID }} + service_account_key: ${{ secrets.GCP_SA_KEY }} + export_default_credentials: true + + - name: Trigger Cloud Build + run: | + gcloud builds submit --config cloudbuild.yaml diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 0000000000..1d5849dc9b --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,44 @@ +steps: + # Build the container image + - name: "gcr.io/cloud-builders/docker" + args: + [ + "build", + "-t", + "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA", + ".", + ] + + # Push the container image to Artifact Registry + - name: "gcr.io/cloud-builders/docker" + args: + [ + "push", + "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA", + ] + + # Deploy container image to GKE + - name: "gcr.io/cloud-builders/gke-deploy" + args: + - run + - --filename=kubernetes-manifests + - --image=asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA + - --location=asia-southeast1 + - --cluster=cs3219-g11-peerprep-kubes + + # Update the deployment to use the new image + - name: "gcr.io/cloud-builders/kubectl" + args: + - "set" + - "image" + - "deployment/peerprep-fe" + - "peerprep-fe=asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA" + env: + - "CLOUDSDK_COMPUTE_ZONE=asia-southeast1" + - "CLOUDSDK_CONTAINER_CLUSTER=cs3219-g11-peerprep-kubes" + +options: + dynamic_substitutions: true + +images: + - "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA" From 0981df84d80e745740aef0d811e267acb0f3afc3 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Tue, 8 Oct 2024 18:39:54 +0800 Subject: [PATCH 02/25] test --- .github/workflows/deploy.yml | 2 +- cloudbuild.yaml | 56 +++++++++++++++++++++++++++++++----- k8s/peerprep-fe.yml | 24 ++++++++-------- k8s/question-service.yml | 30 +++++++++---------- 4 files changed, 77 insertions(+), 35 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d85890a3eb..f3e76732f9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,7 +3,7 @@ name: Deploy to GCP on: push: branches: - - main + - feat/35-continuous-deployment jobs: deploy: diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 1d5849dc9b..9ac150d01b 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -1,15 +1,15 @@ steps: - # Build the container image + # Build and push frontend image - name: "gcr.io/cloud-builders/docker" args: [ "build", "-t", "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA", - ".", + "--target", + "production", + "./peerprep-fe", ] - - # Push the container image to Artifact Registry - name: "gcr.io/cloud-builders/docker" args: [ @@ -17,22 +17,62 @@ steps: "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA", ] - # Deploy container image to GKE + # Build and push question-service image + - name: "gcr.io/cloud-builders/docker" + args: + [ + "build", + "-t", + "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/question-svc:$COMMIT_SHA", + "--target", + "production", + "./question-service", + ] + - name: "gcr.io/cloud-builders/docker" + args: + [ + "push", + "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/question-svc:$COMMIT_SHA", + ] + + # Build and push user-service image + - name: "gcr.io/cloud-builders/docker" + args: + [ + "build", + "-t", + "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/user-svc:$COMMIT_SHA", + "--target", + "production", + "./user-service", + ] + - name: "gcr.io/cloud-builders/docker" + args: + [ + "push", + "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/user-svc:$COMMIT_SHA", + ] + + # Deploy to GKE - name: "gcr.io/cloud-builders/gke-deploy" args: - run - --filename=kubernetes-manifests - - --image=asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA + - --image=asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA,asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/question-svc:$COMMIT_SHA,asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/user-svc:$COMMIT_SHA - --location=asia-southeast1 - --cluster=cs3219-g11-peerprep-kubes - # Update the deployment to use the new image + # Update the deployments to use the new images - name: "gcr.io/cloud-builders/kubectl" args: - "set" - "image" - "deployment/peerprep-fe" - "peerprep-fe=asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA" + - "deployment/question-service" + - "question-service=asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/question-svc:$COMMIT_SHA" + - "deployment/user-service" + - "user-service=asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/user-svc:$COMMIT_SHA" env: - "CLOUDSDK_COMPUTE_ZONE=asia-southeast1" - "CLOUDSDK_CONTAINER_CLUSTER=cs3219-g11-peerprep-kubes" @@ -42,3 +82,5 @@ options: images: - "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA" + - "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/question-svc:$COMMIT_SHA" + - "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/user-svc:$COMMIT_SHA" diff --git a/k8s/peerprep-fe.yml b/k8s/peerprep-fe.yml index 9aaad2ce8d..48f25c13b9 100644 --- a/k8s/peerprep-fe.yml +++ b/k8s/peerprep-fe.yml @@ -1,6 +1,6 @@ apiVersion: apps/v1 kind: Deployment -metadata: +metadata: name: peerprep-fe labels: type: frontend @@ -18,11 +18,11 @@ spec: app: peerprep-fe spec: containers: - - name: peerprep-fe - image: asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest - # imagePullPolicy: Never # only used for local builds - ports: - - containerPort: 3000 + - name: peerprep-fe + image: asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest + # imagePullPolicy: Never # only used for local builds + ports: + - containerPort: 3000 --- apiVersion: v1 kind: Service @@ -49,9 +49,9 @@ spec: minReplicas: 1 maxReplicas: 5 metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: 80 \ No newline at end of file + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 80 diff --git a/k8s/question-service.yml b/k8s/question-service.yml index a08f47df10..403913d928 100644 --- a/k8s/question-service.yml +++ b/k8s/question-service.yml @@ -1,6 +1,6 @@ apiVersion: apps/v1 kind: Deployment -metadata: +metadata: name: question-svc labels: type: backend @@ -18,14 +18,14 @@ spec: app: question-svc spec: containers: - - name: question-svc - image: asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/question-svc:latest - # imagePullPolicy: Never # only used for local builds - ports: - - containerPort: 4001 - envFrom: - - configMapRef: - name: question-service-config + - name: question-svc + image: asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/question-svc:latest + # imagePullPolicy: Never # only used for local builds + ports: + - containerPort: 4001 + envFrom: + - configMapRef: + name: question-service-config dnsPolicy: ClusterFirst --- # This is an internal service, not exposed @@ -54,9 +54,9 @@ spec: minReplicas: 1 maxReplicas: 5 metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: 80 \ No newline at end of file + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 80 From 367284930889b26230ab16d166fabce42665aa5e Mon Sep 17 00:00:00 2001 From: simbayippy Date: Tue, 8 Oct 2024 18:52:29 +0800 Subject: [PATCH 03/25] revert --- cloudbuild.yaml | 56 +++++++------------------------------------------ 1 file changed, 7 insertions(+), 49 deletions(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 9ac150d01b..1d5849dc9b 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -1,78 +1,38 @@ steps: - # Build and push frontend image + # Build the container image - name: "gcr.io/cloud-builders/docker" args: [ "build", "-t", "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA", - "--target", - "production", - "./peerprep-fe", - ] - - name: "gcr.io/cloud-builders/docker" - args: - [ - "push", - "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA", + ".", ] - # Build and push question-service image - - name: "gcr.io/cloud-builders/docker" - args: - [ - "build", - "-t", - "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/question-svc:$COMMIT_SHA", - "--target", - "production", - "./question-service", - ] + # Push the container image to Artifact Registry - name: "gcr.io/cloud-builders/docker" args: [ "push", - "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/question-svc:$COMMIT_SHA", - ] - - # Build and push user-service image - - name: "gcr.io/cloud-builders/docker" - args: - [ - "build", - "-t", - "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/user-svc:$COMMIT_SHA", - "--target", - "production", - "./user-service", - ] - - name: "gcr.io/cloud-builders/docker" - args: - [ - "push", - "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/user-svc:$COMMIT_SHA", + "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA", ] - # Deploy to GKE + # Deploy container image to GKE - name: "gcr.io/cloud-builders/gke-deploy" args: - run - --filename=kubernetes-manifests - - --image=asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA,asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/question-svc:$COMMIT_SHA,asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/user-svc:$COMMIT_SHA + - --image=asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA - --location=asia-southeast1 - --cluster=cs3219-g11-peerprep-kubes - # Update the deployments to use the new images + # Update the deployment to use the new image - name: "gcr.io/cloud-builders/kubectl" args: - "set" - "image" - "deployment/peerprep-fe" - "peerprep-fe=asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA" - - "deployment/question-service" - - "question-service=asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/question-svc:$COMMIT_SHA" - - "deployment/user-service" - - "user-service=asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/user-svc:$COMMIT_SHA" env: - "CLOUDSDK_COMPUTE_ZONE=asia-southeast1" - "CLOUDSDK_CONTAINER_CLUSTER=cs3219-g11-peerprep-kubes" @@ -82,5 +42,3 @@ options: images: - "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA" - - "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/question-svc:$COMMIT_SHA" - - "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/user-svc:$COMMIT_SHA" From f81b8f345b4deeb7c6e00798c378a59adf97f222 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Wed, 9 Oct 2024 23:21:55 +0800 Subject: [PATCH 04/25] attempt --- cloudbuild.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 1d5849dc9b..a0da42011f 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -5,7 +5,7 @@ steps: [ "build", "-t", - "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA", + "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA", ".", ] @@ -14,7 +14,7 @@ steps: args: [ "push", - "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA", + "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA", ] # Deploy container image to GKE @@ -22,7 +22,7 @@ steps: args: - run - --filename=kubernetes-manifests - - --image=asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA + - --image=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA - --location=asia-southeast1 - --cluster=cs3219-g11-peerprep-kubes @@ -32,7 +32,7 @@ steps: - "set" - "image" - "deployment/peerprep-fe" - - "peerprep-fe=asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA" + - "peerprep-fe=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA" env: - "CLOUDSDK_COMPUTE_ZONE=asia-southeast1" - "CLOUDSDK_CONTAINER_CLUSTER=cs3219-g11-peerprep-kubes" @@ -41,4 +41,4 @@ options: dynamic_substitutions: true images: - - "asia-southeast1-docker.pkg.dev/$PROJECT_ID/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA" + - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA" From e1fa6479e7f3df2ed38dbd24c879f307e6a92932 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Wed, 9 Oct 2024 23:28:38 +0800 Subject: [PATCH 05/25] change cloud build to use laatest gcloud v2 --- .github/workflows/deploy.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f3e76732f9..6a6f5017c0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,11 +12,9 @@ jobs: - uses: actions/checkout@v2 - name: Set up Cloud SDK - uses: google-github-actions/setup-gcloud@v0 + uses: google-github-actions/setup-gcloud@v2 with: - project_id: ${{ secrets.GCP_PROJECT_ID }} - service_account_key: ${{ secrets.GCP_SA_KEY }} - export_default_credentials: true + credentials_json: ${{ secrets.GCP_SA_KEY }} - name: Trigger Cloud Build run: | From b7351e83109f5659b447d3df14fe853f7a22f5b3 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Wed, 9 Oct 2024 23:33:29 +0800 Subject: [PATCH 06/25] add authentication first --- .github/workflows/deploy.yml | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6a6f5017c0..050b7b6a6a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,15 +7,27 @@ on: jobs: deploy: + permissions: + contents: "read" + id-token: "write" + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + + - id: "auth" + name: "Authenticate to Google Cloud" + uses: "google-github-actions/auth@v2" + with: + credentials_json: "${{ secrets.GCP_SA_KEY }}" - - name: Set up Cloud SDK - uses: google-github-actions/setup-gcloud@v2 + - name: "Set up Cloud SDK" + uses: "google-github-actions/setup-gcloud@v2" with: - credentials_json: ${{ secrets.GCP_SA_KEY }} + project_id: ${{ secrets.GCP_PROJECT_ID }} + + - name: "Use gcloud CLI" + run: "gcloud info" - - name: Trigger Cloud Build - run: | - gcloud builds submit --config cloudbuild.yaml + - name: "Trigger Cloud Build" + run: "gcloud builds submit --config cloudbuild.yaml" From b76d1b786f2255de2f6b60aa82e5cb50a73c8e02 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Wed, 9 Oct 2024 23:39:37 +0800 Subject: [PATCH 07/25] only cloud logging? --- .github/workflows/deploy.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 050b7b6a6a..bf8d784907 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,3 +31,6 @@ jobs: - name: "Trigger Cloud Build" run: "gcloud builds submit --config cloudbuild.yaml" + + options: + logging: CLOUD_LOGGING_ONLY From 27c51c9a1f7e2c1a485618ea45ca24b9226b72a6 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Wed, 9 Oct 2024 23:43:33 +0800 Subject: [PATCH 08/25] change --- .github/workflows/deploy.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bf8d784907..050b7b6a6a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,6 +31,3 @@ jobs: - name: "Trigger Cloud Build" run: "gcloud builds submit --config cloudbuild.yaml" - - options: - logging: CLOUD_LOGGING_ONLY From 11bda374eff3faf61a9f9fac4e2f31e21844c4a9 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Wed, 9 Oct 2024 23:51:54 +0800 Subject: [PATCH 09/25] attempt --- .github/workflows/deploy.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 050b7b6a6a..22bd4080dc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,8 +23,6 @@ jobs: - name: "Set up Cloud SDK" uses: "google-github-actions/setup-gcloud@v2" - with: - project_id: ${{ secrets.GCP_PROJECT_ID }} - name: "Use gcloud CLI" run: "gcloud info" From b776d4cea243b61858c9f6f6379d2922d5450f70 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Wed, 9 Oct 2024 23:54:40 +0800 Subject: [PATCH 10/25] change from sha to latest --- cloudbuild.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index a0da42011f..a78ad858c5 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -14,7 +14,7 @@ steps: args: [ "push", - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA", + "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest", ] # Deploy container image to GKE @@ -22,7 +22,7 @@ steps: args: - run - --filename=kubernetes-manifests - - --image=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA + - --image=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest - --location=asia-southeast1 - --cluster=cs3219-g11-peerprep-kubes @@ -32,7 +32,7 @@ steps: - "set" - "image" - "deployment/peerprep-fe" - - "peerprep-fe=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA" + - "peerprep-fe=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest" env: - "CLOUDSDK_COMPUTE_ZONE=asia-southeast1" - "CLOUDSDK_CONTAINER_CLUSTER=cs3219-g11-peerprep-kubes" @@ -41,4 +41,4 @@ options: dynamic_substitutions: true images: - - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA" + - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest" From 21792f2592c9a05864b586707a817eb8f0597b3a Mon Sep 17 00:00:00 2001 From: simbayippy Date: Wed, 9 Oct 2024 23:56:04 +0800 Subject: [PATCH 11/25] change from sha to latest --- cloudbuild.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index a78ad858c5..5ccc76ed74 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -5,7 +5,7 @@ steps: [ "build", "-t", - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:$COMMIT_SHA", + "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest", ".", ] From 21d790687ec7986fb7ae0c351ed52941cecc11f0 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Thu, 10 Oct 2024 00:04:00 +0800 Subject: [PATCH 12/25] update docker file location --- cloudbuild.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 5ccc76ed74..c4991680f4 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -6,7 +6,9 @@ steps: "build", "-t", "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest", - ".", + "-f", + "peerprep-fe/Dockerfile", + "peerprep-fe", ] # Push the container image to Artifact Registry From eff1262da431fe8775309e1bcb5cf70838c64139 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Thu, 10 Oct 2024 00:10:30 +0800 Subject: [PATCH 13/25] point to right manifest file --- cloudbuild.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index c4991680f4..bfb4e316d3 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -23,7 +23,7 @@ steps: - name: "gcr.io/cloud-builders/gke-deploy" args: - run - - --filename=kubernetes-manifests + - --filename=k8s/peerprep-fe.yml - --image=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest - --location=asia-southeast1 - --cluster=cs3219-g11-peerprep-kubes From fe0365886b14627d80d2ec501a09b36c8444339e Mon Sep 17 00:00:00 2001 From: simbayippy Date: Thu, 10 Oct 2024 00:20:42 +0800 Subject: [PATCH 14/25] change to fix-auth branch --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 22bd4080dc..3ed45eb2b6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,7 +3,7 @@ name: Deploy to GCP on: push: branches: - - feat/35-continuous-deployment + - feat/fix-auth jobs: deploy: From 1555ba0c1374d06cb674b260e23964854036d4f9 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Thu, 10 Oct 2024 01:13:23 +0800 Subject: [PATCH 15/25] add cloudbuilds for question and user service --- .github/workflows/deploy.yml | 2 +- cloudbuild.yaml | 86 ++++++++++++++++++++++++++++++++++-- k8s/user-service.yml | 60 +++++++++++++++++++++++++ 3 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 k8s/user-service.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3ed45eb2b6..22bd4080dc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,7 +3,7 @@ name: Deploy to GCP on: push: branches: - - feat/fix-auth + - feat/35-continuous-deployment jobs: deploy: diff --git a/cloudbuild.yaml b/cloudbuild.yaml index bfb4e316d3..6714daa721 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -1,5 +1,5 @@ steps: - # Build the container image + # Build and push peerprep-fe - name: "gcr.io/cloud-builders/docker" args: [ @@ -19,7 +19,45 @@ steps: "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest", ] - # Deploy container image to GKE + # Build and push question-service + - name: "gcr.io/cloud-builders/docker" + args: + [ + "build", + "-t", + "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/question-svc:latest", + "-f", + "question-service/Dockerfile", + "question-service", + ] + + - name: "gcr.io/cloud-builders/docker" + args: + [ + "push", + "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/question-svc:latest", + ] + + # Build and push user-service + - name: "gcr.io/cloud-builders/docker" + args: + [ + "build", + "-t", + "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/user-svc:latest", + "-f", + "user-service/Dockerfile", + "user-service", + ] + + - name: "gcr.io/cloud-builders/docker" + args: + [ + "push", + "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/user-svc:latest", + ] + + # Deploy peerprep-fe to Google Kubernetes Engine (GKE) - name: "gcr.io/cloud-builders/gke-deploy" args: - run @@ -28,7 +66,25 @@ steps: - --location=asia-southeast1 - --cluster=cs3219-g11-peerprep-kubes - # Update the deployment to use the new image + # Deploy question-service to Google Kubernetes Engine (GKE) + - name: "gcr.io/cloud-builders/gke-deploy" + args: + - run + - --filename=k8s/question-service.yml + - --image=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/question-svc:latest + - --location=asia-southeast1 + - --cluster=cs3219-g11-peerprep-kubes + + # Deploy user-service to Google Kubernetes Engine (GKE) + - name: "gcr.io/cloud-builders/gke-deploy" + args: + - run + - --filename=k8s/user-service.yml + - --image=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/user-svc:latest + - --location=asia-southeast1 + - --cluster=cs3219-g11-peerprep-kubes + + # Update the peerprep-fe deployment - name: "gcr.io/cloud-builders/kubectl" args: - "set" @@ -39,8 +95,32 @@ steps: - "CLOUDSDK_COMPUTE_ZONE=asia-southeast1" - "CLOUDSDK_CONTAINER_CLUSTER=cs3219-g11-peerprep-kubes" + # Update the question-service deployment + - name: "gcr.io/cloud-builders/kubectl" + args: + - "set" + - "image" + - "deployment/question-svc" + - "question-svc=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/question-svc:latest" + env: + - "CLOUDSDK_COMPUTE_ZONE=asia-southeast1" + - "CLOUDSDK_CONTAINER_CLUSTER=cs3219-g11-peerprep-kubes" + + # Update the user-service deployment + - name: "gcr.io/cloud-builders/kubectl" + args: + - "set" + - "image" + - "deployment/user-svc" + - "user-svc=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/user-svc:latest" + env: + - "CLOUDSDK_COMPUTE_ZONE=asia-southeast1" + - "CLOUDSDK_CONTAINER_CLUSTER=cs3219-g11-peerprep-kubes" + options: dynamic_substitutions: true images: - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest" + - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/question-svc:latest" + - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/user-svc:latest" diff --git a/k8s/user-service.yml b/k8s/user-service.yml new file mode 100644 index 0000000000..bc9ed28a8e --- /dev/null +++ b/k8s/user-service.yml @@ -0,0 +1,60 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: user-svc + labels: + type: backend + app: user-svc +spec: + selector: + matchLabels: + type: backend + app: user-svc + template: + metadata: + name: user-svc + labels: + type: backend + app: user-svc + spec: + containers: + - name: user-svc + image: asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/user-svc:latest + ports: + - containerPort: 3001 + envFrom: + - configMapRef: + name: user-service-config + dnsPolicy: ClusterFirst +--- +apiVersion: v1 +kind: Service +metadata: + name: user-svc +spec: + type: LoadBalancer + ports: + - port: 3001 + targetPort: 3001 + selector: + type: backend + app: user-svc +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: user-svc +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: user-svc + minReplicas: 1 + maxReplicas: 5 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 80 From 96170a99422c9c5b3540465a5b5bbc847991b4f0 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Thu, 10 Oct 2024 01:41:30 +0800 Subject: [PATCH 16/25] cleanup before deploying to GKE --- cloudbuild.yaml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 6714daa721..b17ac26b96 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -1,4 +1,6 @@ steps: + # Step 1: build and push all images to Artifact Registry + # Build and push peerprep-fe - name: "gcr.io/cloud-builders/docker" args: @@ -11,7 +13,7 @@ steps: "peerprep-fe", ] - # Push the container image to Artifact Registry + # Push the peerprep-fe image to Artifact Registry - name: "gcr.io/cloud-builders/docker" args: [ @@ -31,6 +33,7 @@ steps: "question-service", ] + # Push the question-service image to Artifact Registry - name: "gcr.io/cloud-builders/docker" args: [ @@ -50,6 +53,7 @@ steps: "user-service", ] + # Push the user-service image to Artifact Registry - name: "gcr.io/cloud-builders/docker" args: [ @@ -57,6 +61,12 @@ steps: "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/user-svc:latest", ] + # Step 2: Clean up and deploy to GKE + + # Clean up before deploying peerprep-fe + - name: "ubuntu" + args: ["rm", "-rf", "output"] + # Deploy peerprep-fe to Google Kubernetes Engine (GKE) - name: "gcr.io/cloud-builders/gke-deploy" args: @@ -66,6 +76,10 @@ steps: - --location=asia-southeast1 - --cluster=cs3219-g11-peerprep-kubes + # Clean up before deploying question-service + - name: "ubuntu" + args: ["rm", "-rf", "output"] + # Deploy question-service to Google Kubernetes Engine (GKE) - name: "gcr.io/cloud-builders/gke-deploy" args: @@ -75,6 +89,10 @@ steps: - --location=asia-southeast1 - --cluster=cs3219-g11-peerprep-kubes + # Clean up before deploying user-service + - name: "ubuntu" + args: ["rm", "-rf", "output"] + # Deploy user-service to Google Kubernetes Engine (GKE) - name: "gcr.io/cloud-builders/gke-deploy" args: @@ -84,6 +102,8 @@ steps: - --location=asia-southeast1 - --cluster=cs3219-g11-peerprep-kubes + # Step 3: update the deployments with the new images + # Update the peerprep-fe deployment - name: "gcr.io/cloud-builders/kubectl" args: From 460587cbb7900d145db7cc8642a16de5b0548847 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Thu, 10 Oct 2024 03:18:06 +0800 Subject: [PATCH 17/25] try 1 less service --- cloudbuild.yaml | 80 ++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index b17ac26b96..026c183bcf 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -2,24 +2,24 @@ steps: # Step 1: build and push all images to Artifact Registry # Build and push peerprep-fe - - name: "gcr.io/cloud-builders/docker" - args: - [ - "build", - "-t", - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest", - "-f", - "peerprep-fe/Dockerfile", - "peerprep-fe", - ] - - # Push the peerprep-fe image to Artifact Registry - - name: "gcr.io/cloud-builders/docker" - args: - [ - "push", - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest", - ] + # - name: "gcr.io/cloud-builders/docker" + # args: + # [ + # "build", + # "-t", + # "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest", + # "-f", + # "peerprep-fe/Dockerfile", + # "peerprep-fe", + # ] + + # # Push the peerprep-fe image to Artifact Registry + # - name: "gcr.io/cloud-builders/docker" + # args: + # [ + # "push", + # "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest", + # ] # Build and push question-service - name: "gcr.io/cloud-builders/docker" @@ -64,17 +64,17 @@ steps: # Step 2: Clean up and deploy to GKE # Clean up before deploying peerprep-fe - - name: "ubuntu" - args: ["rm", "-rf", "output"] - - # Deploy peerprep-fe to Google Kubernetes Engine (GKE) - - name: "gcr.io/cloud-builders/gke-deploy" - args: - - run - - --filename=k8s/peerprep-fe.yml - - --image=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest - - --location=asia-southeast1 - - --cluster=cs3219-g11-peerprep-kubes + # - name: "ubuntu" + # args: ["rm", "-rf", "output"] + + # # Deploy peerprep-fe to Google Kubernetes Engine (GKE) + # - name: "gcr.io/cloud-builders/gke-deploy" + # args: + # - run + # - --filename=k8s/peerprep-fe.yml + # - --image=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest + # - --location=asia-southeast1 + # - --cluster=cs3219-g11-peerprep-kubes # Clean up before deploying question-service - name: "ubuntu" @@ -105,15 +105,15 @@ steps: # Step 3: update the deployments with the new images # Update the peerprep-fe deployment - - name: "gcr.io/cloud-builders/kubectl" - args: - - "set" - - "image" - - "deployment/peerprep-fe" - - "peerprep-fe=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest" - env: - - "CLOUDSDK_COMPUTE_ZONE=asia-southeast1" - - "CLOUDSDK_CONTAINER_CLUSTER=cs3219-g11-peerprep-kubes" + # - name: "gcr.io/cloud-builders/kubectl" + # args: + # - "set" + # - "image" + # - "deployment/peerprep-fe" + # - "peerprep-fe=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest" + # env: + # - "CLOUDSDK_COMPUTE_ZONE=asia-southeast1" + # - "CLOUDSDK_CONTAINER_CLUSTER=cs3219-g11-peerprep-kubes" # Update the question-service deployment - name: "gcr.io/cloud-builders/kubectl" @@ -126,7 +126,7 @@ steps: - "CLOUDSDK_COMPUTE_ZONE=asia-southeast1" - "CLOUDSDK_CONTAINER_CLUSTER=cs3219-g11-peerprep-kubes" - # Update the user-service deployment + # Update the user-service deployment hi - name: "gcr.io/cloud-builders/kubectl" args: - "set" @@ -141,6 +141,6 @@ options: dynamic_substitutions: true images: - - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest" + # - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest" - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/question-svc:latest" - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/user-svc:latest" From ed0af95c18aeae03d15429de76778941816a4559 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Thu, 10 Oct 2024 03:39:34 +0800 Subject: [PATCH 18/25] add sercret ref to gke --- k8s/user-service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/user-service.yml b/k8s/user-service.yml index bc9ed28a8e..8d2d45576b 100644 --- a/k8s/user-service.yml +++ b/k8s/user-service.yml @@ -23,7 +23,7 @@ spec: ports: - containerPort: 3001 envFrom: - - configMapRef: + - secretRef: name: user-service-config dnsPolicy: ClusterFirst --- From 1a7fd87296d7a0b5f7e20fd07e9ccbfaf957523f Mon Sep 17 00:00:00 2001 From: simbayippy Date: Thu, 10 Oct 2024 03:45:50 +0800 Subject: [PATCH 19/25] fix manifest, now CD piple finished --- cloudbuild.yaml | 78 ++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 026c183bcf..75bb506d5d 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -2,24 +2,24 @@ steps: # Step 1: build and push all images to Artifact Registry # Build and push peerprep-fe - # - name: "gcr.io/cloud-builders/docker" - # args: - # [ - # "build", - # "-t", - # "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest", - # "-f", - # "peerprep-fe/Dockerfile", - # "peerprep-fe", - # ] - - # # Push the peerprep-fe image to Artifact Registry - # - name: "gcr.io/cloud-builders/docker" - # args: - # [ - # "push", - # "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest", - # ] + - name: "gcr.io/cloud-builders/docker" + args: + [ + "build", + "-t", + "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest", + "-f", + "peerprep-fe/Dockerfile", + "peerprep-fe", + ] + + # Push the peerprep-fe image to Artifact Registry + - name: "gcr.io/cloud-builders/docker" + args: + [ + "push", + "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest", + ] # Build and push question-service - name: "gcr.io/cloud-builders/docker" @@ -64,17 +64,17 @@ steps: # Step 2: Clean up and deploy to GKE # Clean up before deploying peerprep-fe - # - name: "ubuntu" - # args: ["rm", "-rf", "output"] - - # # Deploy peerprep-fe to Google Kubernetes Engine (GKE) - # - name: "gcr.io/cloud-builders/gke-deploy" - # args: - # - run - # - --filename=k8s/peerprep-fe.yml - # - --image=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest - # - --location=asia-southeast1 - # - --cluster=cs3219-g11-peerprep-kubes + - name: "ubuntu" + args: ["rm", "-rf", "output"] + + # Deploy peerprep-fe to Google Kubernetes Engine (GKE) + - name: "gcr.io/cloud-builders/gke-deploy" + args: + - run + - --filename=k8s/peerprep-fe.yml + - --image=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest + - --location=asia-southeast1 + - --cluster=cs3219-g11-peerprep-kubes # Clean up before deploying question-service - name: "ubuntu" @@ -105,15 +105,15 @@ steps: # Step 3: update the deployments with the new images # Update the peerprep-fe deployment - # - name: "gcr.io/cloud-builders/kubectl" - # args: - # - "set" - # - "image" - # - "deployment/peerprep-fe" - # - "peerprep-fe=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest" - # env: - # - "CLOUDSDK_COMPUTE_ZONE=asia-southeast1" - # - "CLOUDSDK_CONTAINER_CLUSTER=cs3219-g11-peerprep-kubes" + - name: "gcr.io/cloud-builders/kubectl" + args: + - "set" + - "image" + - "deployment/peerprep-fe" + - "peerprep-fe=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest" + env: + - "CLOUDSDK_COMPUTE_ZONE=asia-southeast1" + - "CLOUDSDK_CONTAINER_CLUSTER=cs3219-g11-peerprep-kubes" # Update the question-service deployment - name: "gcr.io/cloud-builders/kubectl" @@ -141,6 +141,6 @@ options: dynamic_substitutions: true images: - # - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest" + - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest" - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/question-svc:latest" - "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/user-svc:latest" From ef6de7f4b81aacbff5f8a7a16a0fbc6bf3edb1df Mon Sep 17 00:00:00 2001 From: simbayippy Date: Thu, 10 Oct 2024 03:46:31 +0800 Subject: [PATCH 20/25] finish CD, change on-push branch to main --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 22bd4080dc..742ba7b406 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,7 +3,7 @@ name: Deploy to GCP on: push: branches: - - feat/35-continuous-deployment + - main jobs: deploy: From 78c10acc0ce560145f0880af67a87bae178ccb82 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Thu, 10 Oct 2024 04:06:11 +0800 Subject: [PATCH 21/25] test --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 742ba7b406..22bd4080dc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,7 +3,7 @@ name: Deploy to GCP on: push: branches: - - main + - feat/35-continuous-deployment jobs: deploy: From 0e5a893aca374f5f1753e6a8c2839d544a0f740e Mon Sep 17 00:00:00 2001 From: simbayippy Date: Thu, 10 Oct 2024 04:09:05 +0800 Subject: [PATCH 22/25] test passed, change target branch back to main --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 22bd4080dc..742ba7b406 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,7 +3,7 @@ name: Deploy to GCP on: push: branches: - - feat/35-continuous-deployment + - main jobs: deploy: From 61f18065ea3693c76584265e2156089e7041ee23 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Thu, 10 Oct 2024 04:19:23 +0800 Subject: [PATCH 23/25] change question service from configMap to sercretRef --- k8s/question-service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/question-service.yml b/k8s/question-service.yml index 403913d928..db7cf39900 100644 --- a/k8s/question-service.yml +++ b/k8s/question-service.yml @@ -24,7 +24,7 @@ spec: ports: - containerPort: 4001 envFrom: - - configMapRef: + - secretRef: name: question-service-config dnsPolicy: ClusterFirst --- From 563bf2a346be7576c4de3fdef2240015160b7fd9 Mon Sep 17 00:00:00 2001 From: simbayippy Date: Thu, 10 Oct 2024 04:28:21 +0800 Subject: [PATCH 24/25] set enviornment variables in kubernetes --- .github/workflows/deploy.yml | 2 +- k8s/peerprep-fe.yml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 742ba7b406..22bd4080dc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,7 +3,7 @@ name: Deploy to GCP on: push: branches: - - main + - feat/35-continuous-deployment jobs: deploy: diff --git a/k8s/peerprep-fe.yml b/k8s/peerprep-fe.yml index 48f25c13b9..55b7e43619 100644 --- a/k8s/peerprep-fe.yml +++ b/k8s/peerprep-fe.yml @@ -23,6 +23,10 @@ spec: # imagePullPolicy: Never # only used for local builds ports: - containerPort: 3000 + envFrom: + - secretRef: + name: peerprep-config + dnsPolicy: ClusterFirst --- apiVersion: v1 kind: Service From acdb1a4f5e7ca9634b87f2b9a94158e57a3a79fd Mon Sep 17 00:00:00 2001 From: simbayippy Date: Thu, 10 Oct 2024 04:28:56 +0800 Subject: [PATCH 25/25] set target branch back to main again --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 22bd4080dc..742ba7b406 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,7 +3,7 @@ name: Deploy to GCP on: push: branches: - - feat/35-continuous-deployment + - main jobs: deploy: