File tree Expand file tree Collapse file tree 4 files changed +161
-3
lines changed
Expand file tree Collapse file tree 4 files changed +161
-3
lines changed Original file line number Diff line number Diff line change 1+ name : Continuous Deployment for Video Service
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ env :
9+ PROJECT_ID : gke-project-423206
10+ CLUSTER_NAME : autopilot-cluster-1
11+ ZONE : us-central1
12+
13+ jobs :
14+ deploy :
15+ name : Deploy to GKE Autopilot
16+ runs-on : ubuntu-latest
17+ steps :
18+ - name : Checkout code
19+ uses : actions/checkout@v3
20+
21+ - name : Setup JDK 17
22+ uses : actions/setup-java@v3
23+ with :
24+ distribution : ' corretto'
25+ java-version : 17
26+
27+ - name : Build the application
28+ run : |
29+ mvn clean
30+ mvn -B package --file pom.xml
31+
32+ - name : Authenticate
33+ uses : google-github-actions/auth@v2
34+ with :
35+ credentials_json : ${{ secrets.GCP_SA_KEY }}
36+
37+ - name : Configure gcloud
38+ uses : google-github-actions/setup-gcloud@v2
39+ with :
40+ project_id : ${{ env.PROJECT_ID }}
41+ install_components : ' gke-gcloud-auth-plugin'
42+
43+ - name : Login to Docker Hub
44+ uses : docker/login-action@v1
45+ with :
46+ username : datuits
47+ password : ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
48+
49+ - name : Build and Push the docker image
50+ run : |
51+ docker build -t datuits/devops-video-service:latest .
52+ docker push datuits/devops-video-service:latest
53+
54+ - name : Set cluster context
55+ run : |
56+ gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --zone ${{ env.ZONE }} --project ${{ env.PROJECT_ID }}
57+
58+ - name : Apply Kubernetes manifests
59+ run : |
60+ kubectl apply -f resources.yaml
Original file line number Diff line number Diff line change 1+ name : Continuous Integration for Video Service
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+ build-deploy :
10+ name : Build and Deploy Comment Service
11+ runs-on : ubuntu-latest
12+ steps :
13+ - name : Checkout code
14+ uses : actions/checkout@v3
15+
16+ - name : Setup JDK 17
17+ uses : actions/setup-java@v3
18+ with :
19+ distribution : ' corretto'
20+ java-version : 17
21+
22+ - name : Set up MongoDB URI
23+ run : echo "SPRING_DATA_MONGODB_URI=mongodb://localhost:27017/video-service" >> $GITHUB_ENV
24+
25+ - name : Unit Tests
26+ run : mvn -B test --file pom.xml
Original file line number Diff line number Diff line change 1+ apiVersion : apps/v1
2+ kind : Deployment
3+ metadata :
4+ name : video-mongo-deployment
5+ spec :
6+ replicas : 1
7+ selector :
8+ matchLabels :
9+ app : mongo
10+ template :
11+ metadata :
12+ labels :
13+ app : mongo
14+ spec :
15+ containers :
16+ - name : mongo
17+ image : mongo:latest
18+ ports :
19+ - containerPort : 27017
20+ env :
21+ - name : MONGO_INITDB_DATABASE
22+ value : video-service
23+ ---
24+ apiVersion : v1
25+ kind : Service
26+ metadata :
27+ name : video-mongo-service
28+ spec :
29+ selector :
30+ app : mongo
31+ ports :
32+ - protocol : TCP
33+ port : 27017
34+ targetPort : 27017
35+
36+ ---
37+ apiVersion : apps/v1
38+ kind : Deployment
39+ metadata :
40+ name : video-service
41+ labels :
42+ app : video-service
43+ spec :
44+ replicas : 1
45+ selector :
46+ matchLabels :
47+ app : video-service
48+ template :
49+ metadata :
50+ labels :
51+ app : video-service
52+ spec :
53+ containers :
54+ - name : video-service
55+ image : datuits/devops-video-service:latest
56+ ports :
57+ - containerPort : 8083
58+ env :
59+ - name : SPRING_DATA_MONGODB_URI
60+ value : mongodb://video-mongo-service:27017/video-service
61+ ---
62+ apiVersion : v1
63+ kind : Service
64+ metadata :
65+ name : video-service
66+ spec :
67+ selector :
68+ app : video-service
69+ ports :
70+ - protocol : TCP
71+ port : 8083
72+ targetPort : 8083
73+ type : ClusterIP
Original file line number Diff line number Diff line change 11server :
2- port : 8083
2+ port : 8082
33
44spring :
55 application :
66 name : video-service
77 data :
88 mongodb :
9- # uri: ${SPRING_DATA_MONGODB_URI}
10- uri : mongodb://localhost:27017/video-service
9+ uri : ${SPRING_DATA_MONGODB_URI:mongodb://localhost:27017/video-service}
You can’t perform that action at this time.
0 commit comments