Skip to content

Commit 1c68d05

Browse files
committed
PEER-242: Update actions script
Signed-off-by: SeeuSim <[email protected]>
1 parent dc2d4d7 commit 1c68d05

7 files changed

+67
-34
lines changed

.github/workflows/build-deploy-docker.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,22 +187,22 @@ jobs:
187187
cache-to: type=gha,mode=max
188188

189189
- name: Setup GCloud
190-
uses: google-github-actions/setup-gcloud@v
191-
if: ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' && false }}
190+
uses: google-github-actions/setup-gcloud@v2
191+
if: ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' && secrets.GKE_CLUSTER }}
192192
with:
193193
service_account_key: ${{ secrets.GKE_SA_KEY }}
194194
project_id: ${{ secrets.GKE_PROJECT }}
195195

196196
- name: Get GKE creds
197-
uses: google-github-actions/get-gke-credentials@v
198-
if: ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' && false }}
197+
uses: google-github-actions/get-gke-credentials@v2
198+
if: ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' && secrets.GKE_CLUSTER }}
199199
with:
200-
cluster_name: ${{ env.GKE_CLUSTER }}
201-
location: ${{ env.GKE_ZONE }}
200+
cluster_name: ${{ secrets.GKE_CLUSTER }}
201+
location: ${{ secrets.GKE_ZONE }}
202202
credentials: ${{ secrets.GKE_SA_KEY }}
203203

204204
- name: Deploy to GKE
205-
if: ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' && false }}
205+
if: ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' && secrets.GKE_CLUSTER }}
206206
run: |-
207207
deployments=("collab-service" "matching-service" "question-service" "user-service" "frontend")
208208
for dplymnt in "${deployments[@]}"; do
@@ -217,7 +217,7 @@ jobs:
217217
needs: build-push-deploy-image
218218
steps:
219219
- run: |
220-
result="${{ needs.build-and-push-image.result }}"
220+
result="${{ needs.build-push-deploy-image.result }}"
221221
if [[ $result == "success" || $result == "skipped" ]]; then
222222
exit 0
223223
else

k8s/04-collab-svc-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ spec:
6464
containers:
6565
- name: collab-express
6666
image: ay2425s1cs3219g16/collab-express:latest
67-
imagePullPolicy: IfNotPresent
67+
imagePullPolicy: Always
6868
envFrom:
6969
- secretRef:
7070
name: collaboration-secret

k8s/04-match-svc-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ spec:
7777
containers:
7878
- name: match-express
7979
image: ay2425s1cs3219g16/match-express:latest
80-
imagePullPolicy: IfNotPresent
80+
imagePullPolicy: Always
8181
envFrom:
8282
- secretRef:
8383
name: matching-secret

k8s/04-question-svc-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ spec:
6464
containers:
6565
- name: question-express
6666
image: ay2425s1cs3219g16/question-express:latest
67-
imagePullPolicy: IfNotPresent
67+
imagePullPolicy: Always
6868
envFrom:
6969
- secretRef:
7070
name: question-secret

k8s/04-user-svc-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ spec:
6464
containers:
6565
- name: user-express
6666
image: ay2425s1cs3219g16/user-express:latest
67-
imagePullPolicy: IfNotPresent
67+
imagePullPolicy: Always
6868
envFrom:
6969
- secretRef:
7070
name: user-secret

k8s/05-frontend-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ spec:
6666
containers:
6767
- name: frontend
6868
image: ay2425s1cs3219g16/frontend:latest
69-
imagePullPolicy: IfNotPresent
69+
imagePullPolicy: Always
7070
envFrom:
7171
- secretRef:
7272
name: frontend-secret

k8s/README.md

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@
147147
A browser window should launch, directing you to the application's frontend.
148148
149149
## GKE Instructions
150+
<!-- https://cert-manager.io/docs/tutorials/getting-started-with-cert-manager-on-google-kubernetes-engine-using-lets-encrypt-for-ingress-ssl/ -->
151+
152+
### Setup
150153
151154
1. Authenticate or ensure you are added as a user to the Google Cloud Project:
152155
@@ -209,7 +212,31 @@
209212
7. If you haven't already, visit the GCloud console -> 'Cloud Domains' and verify that a domain name has been created.
210213

211214
- We currently have one as `peerprep-g16.net`.
215+
- This can be created under 'Cloud Domains' -> 'Register Domain' in the GCloud console.
212216
- We also associate a GCloud Global Web IP `web-ip` to this DNS record as an 'A' record.
217+
- To set an IP DNS 'A' record, follow these steps:
218+
1. Create an IP:
219+
220+
```sh
221+
gcloud compute addresses create web-ip --global
222+
```
223+
224+
2. Verify that it exists:
225+
226+
```sh
227+
gcloud compute addresses list
228+
```
229+
230+
3. Grab the IP address:
231+
232+
```sh
233+
gcloud compute addresses describe web-ip --format='value(address)' --global
234+
```
235+
236+
4. Associate it via the console:
237+
- Cloud DNS -> 'Zone Name': peerprep-g16.net -> 'Add standard'
238+
- Paste the IP address
239+
- 'Create'
213240

214241
8. Install the `cert-manager` plugin:
215242

@@ -226,26 +253,7 @@
226253
- After 15 minutes, you should be able to access the UI over HTTPS at this link:
227254
- `https://peerprep-g16.net`
228255

229-
10. Setup the following in Github Actions by:
230-
231-
- heading to the 'Settings' -> 'Secrets and variables' -> 'Actions' -> 'New repository secret'
232-
- Adding the following keys:
233-
234-
```txt
235-
GKE_SA_KEY: <redacted (get from the cloud console page)>
236-
GKE_PROJECT: cs3219-g16
237-
GKE_CLUSTER: cs3219-g16
238-
GKE_ZONE: asia-southeast1-c
239-
240-
```
241-
242-
11. Merge a PR to `main` and verify that the cluster is redeployed with the latest images:
243-
244-
```sh
245-
kubectl -n peerprep get deployment
246-
```
247-
248-
12. Cleanup:
256+
10. Cleanup:
249257

250258
- Delete the cluster:
251259

@@ -260,4 +268,29 @@
260268
261269
gcloud compute addresses delete web-ip --global
262270
```
263-
<!-- https://cert-manager.io/docs/tutorials/getting-started-with-cert-manager-on-google-kubernetes-engine-using-lets-encrypt-for-ingress-ssl/ -->
271+
272+
### CD (Continuous Delivery via Github Actions)
273+
274+
1. Setup the following in Github Actions by:
275+
276+
- heading to the 'Settings' -> 'Secrets and variables' -> 'Actions' -> 'New repository secret'
277+
- Adding the following keys:
278+
279+
```txt
280+
GKE_SA_KEY: <redacted (get from the cloud console IAM -> 'Service Accounts' page)>
281+
GKE_PROJECT: cs3219-g16
282+
GKE_CLUSTER: cs3219-g16
283+
GKE_ZONE: asia-southeast1-c
284+
```
285+
286+
- If the `GKE_SA_KEY` is needed, contact us.
287+
288+
2. Merge a PR to `main`. The following will happend:
289+
290+
1. An action will run under the 'actions' tab in Github.
291+
292+
2. This will build and push the service images and verify that the cluster is redeployed with the latest images:
293+
294+
```sh
295+
kubectl -n peerprep get deployment
296+
```

0 commit comments

Comments
 (0)