Skip to content

Commit 0c0a1b0

Browse files
Mirko ZitkovichMirko Zitkovich
authored andcommitted
Updated README and separated jobs
1 parent cd4688e commit 0c0a1b0

File tree

2 files changed

+32
-54
lines changed

2 files changed

+32
-54
lines changed

.github/workflows/gke-cd.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy FNS API to Cloud Run
1+
name: Deploy FNS API to Cloud Run (Separated Jobs)
22

33
on:
44
push:
@@ -9,8 +9,8 @@ on:
99
- feature/*
1010

1111
jobs:
12-
deploy:
13-
name: Build, Push Docker Image & Deploy to Cloud Run
12+
build-and-push-image:
13+
name: Build and Push Docker Image
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Checkout code
@@ -40,10 +40,23 @@ jobs:
4040
docker build -t $IMAGE_NAME:$IMAGE_TAG .
4141
docker push $IMAGE_NAME:$IMAGE_TAG
4242
43+
deploy-to-cloud-run:
44+
name: Deploy to Cloud Run
45+
runs-on: ubuntu-latest
46+
needs: build-and-push-image # Ensure this job runs after build-and-push-image
47+
steps:
48+
- name: Checkout code (again, if needed for deploy steps - optional)
49+
uses: actions/checkout@v2
50+
51+
- name: Google Cloud Auth # Authenticate gcloud CLI
52+
uses: google-github-actions/auth@v2
53+
with:
54+
credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
55+
4356
- name: Deploy to Cloud Run
4457
uses: google-github-actions/deploy-cloudrun@v1
4558
with:
46-
image: us-central1-docker.pkg.dev/${{ secrets.GOOGLE_PROJECT }}/flex-net-sim-repo/fns-api:latest
59+
image: us-central1-docker.pkg.dev/${{ secrets.GOOGLE_PROJECT }}/flex-net-sim-repo/fns-api:latest # Use the same image as built
4760
service: fns-api-cloud-run
4861
region: us-central1
4962
project_id: ${{ secrets.GOOGLE_PROJECT }}

README.md

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ To stop:
7474
docker stop fns-api
7575
```
7676

77-
## Docs: GCloud Deployment Configuration
77+
## GCloud Deployment Configuration
7878

79-
For detailed step-by-step instructions on configuring Google Cloud (GCloud) aspects such as Kubernetes Cluster creation, Artifact Registry, Service Account creation, and IAM policy binding, please refer to the following video tutorial:
79+
As a prerequisite is mandatory to apply the following steps to the GCloud project for the docker image build and upload to artifacts, and also service account creation and IAM policy binding:
8080

8181
[GCloud Configuration Video Tutorial](https://www.youtube.com/watch?v=KQUKDiBz3IA)
8282

83-
This video will guide you through the necessary configurations in the Google Cloud Console to prepare your project for Kubernetes deployments using GitHub Actions.
83+
This video will guide you through the necessary configurations in the Google Cloud Console to prepare your project for Cloud Run deployments using GitHub Actions.
8484

8585
**Key Reminders from the Video & for Successful Deployment:**
8686

@@ -89,7 +89,7 @@ This video will guide you through the necessary configurations in the Google Clo
8989

9090
**Post-Configuration Steps (using `gcloud` and `cloud-run`):**
9191

92-
1. Activate necesary apis:
92+
1. Activate necessary apis:
9393

9494
* `gcloud services enable run.googleapis.com`
9595

@@ -102,61 +102,26 @@ This video will guide you through the necessary configurations in the Google Clo
102102
* Select the authetification preferences.
103103
* Create.
104104

105-
106-
* Choose a cluster name (e.g., `flex-net-sim-cluster`). **Remember this name.**
107-
* Select a region for your cluster (e.g., `us-central1`).
108-
* For the purpose of this guide, you can use the default settings for node pools, networking, and other configurations, or adjust them based on your specific needs.
109-
* Click **Create** to create the cluster. It will take a few minutes for the cluster to be provisioned.
110-
111-
2. **Set IAM Policy Binding (using `gcloud`):**
112-
113-
Replace `<YOUR-GOOGLE-PROJECT-ID>` and `<SERVICE_ACCOUNT_EMAIL>` with your actual Google Cloud Project ID and the Service Account Email you noted down.
105+
3. Update access of service accounts to cloud run resources:
114106

115107
```bash
116-
gcloud projects add-iam-policy-binding <YOUR-GOOGLE-PROJECT-ID> --member="serviceAccount:<SERVICE_ACCOUNT_EMAIL>" --role="roles/container.admin"
108+
gcloud projects add-iam-policy-binding "<YOUR-GOOGLE-PROJECT-ID>" --member="serviceAccount:<SERVICE_ACCOUNT_EMAIL>" --role="roles/run.admin"
117109
```
118110

119-
3. **Get Kubernetes Cluster Credentials (using `gcloud`):**
120-
121-
Replace `<CLUSTER-NAME>` and `<YOUR-GOOGLE-PROJECT-ID>` with your Kubernetes Cluster Name and Google Cloud Project ID. Ensure the region is set to `us-central1`.
111+
and
122112

123113
```bash
124-
gcloud container clusters get-credentials <CLUSTER-NAME> --region us-central1 --project <YOUR-GOOGLE-PROJECT-ID>
125-
```
114+
gcloud iam service-accounts add-iam-policy-binding "<YOUR_PROJECT_NUMBER>-compute@developer.gserviceaccount.com" --member="serviceAccount:<SERVICE_ACCOUNT_EMAIL>" --role="roles/iam.serviceAccountActor"
115+
```
126116

127-
The command will fetch the cluster credentials and configure `kubectl` to use them. You should see output similar to:
117+
4. **Test the Deployed API (using `curl`):**
128118

129-
```
130-
Fetching cluster endpoint and auth data.
131-
kubeconfig entry generated for <CLUSTER-NAME>.
132-
```
133-
134-
4. **Verify `kubectl` Configuration and Service Deployment (using `kubectl`):**
135-
136-
After the command is successful, verify your `kubectl` configuration and check for the `fns-api-service`:
119+
Use the `curl` command with the `ENDPOINT-URL` you obtained from the previous steps to test your deployed API. Replace `YOUR-ENDPOINT-URL` with the actual `ENDPOINT-URL`.
137120

138121
```bash
139-
kubectl get service fns-api-service
140-
```
141-
142-
If the service is correctly deployed (after your GitHub Actions workflow runs), it should display information about your service, including the `EXTERNAL-IP`.
143-
144-
You should see output similar to this (the `EXTERNAL-IP` will likely be different):
145-
146-
```
147-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
148-
fns-api-service LoadBalancer 10.3.xxx.xxx 34.56.1.247 80:8080/TCP 20h
149-
kubernetes ClusterIP 10.3.xxx.xxx <none> 443/TCP 21h
150-
```
151-
152-
5. **Test the Deployed API (using `curl`):**
153-
154-
Use the `curl` command with the `EXTERNAL-IP` you obtained from the previous step to test your deployed API. Replace `<YOUR-EXTERNAL-IP>` with the actual `EXTERNAL-IP`.
155-
156-
```bash
157-
curl -X POST -H "Content-Type: application/json" -d '{"algorithm": "FirstFit", "networkType": 1, "bitrate": "bitrate"}' http://<YOUR-EXTERNAL-IP>/run_simulation
158-
```
159-
160-
**Remember**: These GCloud configurations, along with the repository's `gke-cd.yml` GitHub Actions workflow and correctly configured GitHub secrets, are essential for successful automated deployment of your FlexNetSim-API application to Google Cloud Kubernetes Engine.
122+
curl -X POST -H "Content-Type: application/json" -d '{"algorithm": "FirstFit", "networkType": 1, "bitrate": "bitrate"}' <YOUR-ENDPOINT-URL>/run_simulation
123+
```
161124

125+
Remember that depending on the authetification preferences you might need to authetificate to send request to the Endpoint just created.
162126

127+
**Remember**: These GCloud configurations, along with the repository's `gke-cd.yml` GitHub Actions workflow and correctly configured GitHub secrets, are essential for successful automated deployment of your FlexNetSim-API application to Google Cloud Run.

0 commit comments

Comments
 (0)