Skip to content

Commit 76823f0

Browse files
Mirko ZitkovichMirko Zitkovich
authored andcommitted
Change to DEPLOY process and debug from develop
1 parent dfa8945 commit 76823f0

File tree

2 files changed

+75
-19
lines changed

2 files changed

+75
-19
lines changed

.github/workflows/gke-cd.yml

Lines changed: 74 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,87 @@ name: Deploy FNS API
33
on:
44
push:
55
branches:
6-
- master
6+
- develop
77
pull_request:
88
branches:
9-
- master
9+
- develop
1010

1111
jobs:
1212
deploy:
13-
name: Build and Push Docker Image
13+
name: Build, Push Docker Image & Deploy to Kubernetes
1414
runs-on: ubuntu-latest
1515
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v2
1618

17-
- name: Checkout code
18-
uses: actions/checkout@v2
19+
- name: Set up Google Cloud CLI
20+
uses: google-github-actions/setup-gcloud@v0
21+
with:
22+
service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
23+
project_id: ${{ secrets.GOOGLE_PROJECT }}
24+
export_default_credentials: true
1925

20-
- name: Set up Google CLoud CLI
21-
uses: google-github-actions/setup-gcloud@v0
22-
with:
23-
service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
24-
project_id: ${{ secrets.GOOGLE_PROJECT }}
25-
export_default_credentials: true
26+
- name: Configure Docker to push to Artifact Registry
27+
run: |
28+
gcloud auth configure-docker us-central1-docker.pkg.dev
2629
27-
- name: Build and push Docker image
28-
env:
29-
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
30-
run: |
31-
gcloud auth configure-docker us-central1-docker.pkg.dev
32-
docker build -t us-central1-docker.pkg.dev/$GOOGLE_PROJECT/flex-net-sim-repo/fns-api:latest .
33-
docker push us-central1-docker.pkg.dev/$GOOGLE_PROJECT/flex-net-sim-repo/fns-api:latest
30+
- name: Build and Push Docker image to Artifact Registry
31+
env:
32+
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
33+
IMAGE_NAME: us-central1-docker.pkg.dev/$GOOGLE_PROJECT/flex-net-sim-repo/fns-api
34+
IMAGE_TAG: latest
35+
run: |
36+
docker build -t $IMAGE_NAME:$IMAGE_TAG .
37+
docker push $IMAGE_NAME:$IMAGE_TAG
38+
39+
- name: Get Kubernetes cluster credentials
40+
env:
41+
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
42+
CLUSTER_NAME: flex-net-sim-cluster
43+
CLUSTER_REGION: us-central1
44+
run: |
45+
gcloud container clusters get-credentials $CLUSTER_NAME --region $CLUSTER_REGION --project $GOOGLE_PROJECT
46+
47+
- name: Deploy to Kubernetes cluster
48+
env:
49+
DEPLOYMENT_NAME: fns-api-deployment
50+
NAMESPACE: default # Replace with your namespace if needed
51+
IMAGE_NAME: us-central1-docker.pkg.dev/$GOOGLE_PROJECT/flex-net-sim-repo/fns-api
52+
IMAGE_TAG: latest
53+
run: |
54+
kubectl apply -f - <<EOF
55+
apiVersion: apps/v1
56+
kind: Deployment
57+
metadata:
58+
name: $DEPLOYMENT_NAME
59+
namespace: $NAMESPACE
60+
spec:
61+
replicas: 2 # Adjust as needed
62+
selector:
63+
matchLabels:
64+
app: fns-api
65+
template:
66+
metadata:
67+
labels:
68+
app: fns-api
69+
spec:
70+
containers:
71+
- name: fns-api-container
72+
image: $IMAGE_NAME:$IMAGE_TAG
73+
ports:
74+
- containerPort: 8080 # Replace with your application port
75+
---
76+
apiVersion: v1
77+
kind: Service
78+
metadata:
79+
name: fns-api-service
80+
namespace: $NAMESPACE
81+
spec:
82+
selector:
83+
app: fns-api
84+
ports:
85+
- protocol: TCP
86+
port: 80
87+
targetPort: 8080 # Replace with your application port
88+
type: LoadBalancer
89+
EOF

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Flex Net Sim Backend API
22

3-
This is a Flask-based backend API that runs the FlexNetSim C++ library. It is an unofficial API that powers the backend for the web app deployed at [www.in-progress.com](www.in-progress.com).
3+
Flask-based backend API for integrating the FlexNetSim C++ library, powering the web application deployed at [www.in-progress.com](www.in-progress.com). This unofficial API facilitates seamless interaction between the simulation engine and the web interface.
44

55
## Prerequisites
66

0 commit comments

Comments
 (0)