File tree Expand file tree Collapse file tree 15 files changed +127
-43
lines changed
main/java/com/programming/userService
com/programming/userService Expand file tree Collapse file tree 15 files changed +127
-43
lines changed Original file line number Diff line number Diff line change 1-
21name : Continuous Deployment for User Service
32
43on :
5- push :
6- branches :
7- - main
4+ workflow_run :
5+ workflows : ["Continuous Integration for Comment Service"]
6+ types :
7+ - completed
88
99env :
1010 PROJECT_ID : gke-project-423206
@@ -29,33 +29,28 @@ jobs:
2929 run : |
3030 mvn clean
3131 mvn -B package --file pom.xml
32-
32+
3333 - name : Authenticate
3434 uses : google-github-actions/auth@v2
3535 with :
3636 credentials_json : ${{ secrets.GCP_SA_KEY }}
37-
37+
3838 - name : Configure gcloud
3939 uses : google-github-actions/setup-gcloud@v2
4040 with :
4141 project_id : ${{ env.PROJECT_ID }}
4242 install_components : ' gke-gcloud-auth-plugin'
4343
44- - name : Login to Docker Hub
45- uses : docker/login-action@v1
46- with :
47- username : datuits
48- password : ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
49-
50- - name : Build and Push the docker image
51- run : |
52- docker build -t datuits/devops-user-service:latest .
53- docker push datuits/devops-user-service:latest
54-
5544 - name : Set cluster context
5645 run : |
5746 gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --zone ${{ env.ZONE }} --project ${{ env.PROJECT_ID }}
5847
5948 - name : Apply Kubernetes manifests
6049 run : |
6150 kubectl apply -f resources.yaml
51+
52+ notifications :
53+ needs : deploy
54+ uses : ./.github/workflows/notifyCD.yaml
55+ secrets :
56+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL}}
Original file line number Diff line number Diff line change 1+ name : Send Slack Notification for User Service
2+
3+ on :
4+ workflow_call :
5+ secrets :
6+ SLACK_WEBHOOK_URL :
7+ required : true
8+
9+ jobs :
10+ success_notifier :
11+ if : success()
12+ runs-on : ubuntu-latest
13+ steps :
14+ - name : Send success notification on Slack
15+ 16+ with :
17+ payload : |
18+ {
19+ "text": "The Continuous Deployment for User Service workflow has completed successfully."
20+ }
21+ env :
22+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
23+
24+ failure_notifier :
25+ if : failure()
26+ runs-on : ubuntu-latest
27+ steps :
28+ - name : Send failure notification on Slack
29+ 30+ with :
31+ payload : |
32+ {
33+ "text": "The Continuous Deployment for User Service workflow has failed."
34+ }
35+ env :
36+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
Original file line number Diff line number Diff line change @@ -3,10 +3,10 @@ FROM openjdk:17-jdk
33WORKDIR /app
44
55# Copy the JAR file
6- COPY target/streaming -0.0.1-SNAPSHOT.jar /app/app.jar
6+ COPY target/userService -0.0.1-SNAPSHOT.jar /app/app.jar
77
88# Copy all PNG files from the specific directory to a directory in the Docker container
9- COPY src/main/java/com/programming/streaming /images/*.png /app/images/
9+ COPY src/main/java/com/programming/userService /images/*.png /app/images/
1010
1111# Expose port
1212EXPOSE 8080
Original file line number Diff line number Diff line change 2121 - name : MONGO_INITDB_DATABASE
2222 value : user-service
2323 resources :
24+ requests :
25+ memory : " 32Mi"
26+ cpu : " 0.05"
2427 limits :
25- memory : 256Mi
26- cpu : " 1"
28+ memory : " 64Mi"
29+ cpu : " 0.1"
30+
31+ volumeMounts :
32+ - name : mongo-storage
33+ mountPath : /data/db
34+ volumes :
35+ - name : mongo-storage
36+ persistentVolumeClaim :
37+ claimName : user-mongo-pvc
38+ ---
39+ apiVersion : v1
40+ kind : PersistentVolume
41+ metadata :
42+ name : user-mongo-pv
43+ spec :
44+ capacity :
45+ storage : 70Mi
46+ accessModes :
47+ - ReadWriteOnce
48+ gcePersistentDisk :
49+ pdName : user-mongo-disk
50+ fsType : ext4
51+ ---
52+ apiVersion : v1
53+ kind : PersistentVolumeClaim
54+ metadata :
55+ name : user-mongo-pvc
56+ spec :
57+ accessModes :
58+ - ReadWriteOnce
59+ resources :
60+ requests :
61+ storage : 70Mi
2762---
2863apiVersion : v1
2964kind : Service
3570 ports :
3671 - protocol : TCP
3772 port : 27017
38- targetPort : 27017
39-
73+ targetPort : 27017
Original file line number Diff line number Diff line change 99 <relativePath /> <!-- lookup parent from repository -->
1010 </parent >
1111 <groupId >com.programming</groupId >
12- <artifactId >streaming </artifactId >
12+ <artifactId >userService </artifactId >
1313 <version >0.0.1-SNAPSHOT</version >
14- <name >streaming </name >
14+ <name >userService </name >
1515 <description >Demo project for Spring Boot</description >
1616 <properties >
1717 <java .version>17</java .version>
Original file line number Diff line number Diff line change 1- ---
21apiVersion : apps/v1
32kind : Deployment
43metadata :
2423 - name : SPRING_DATA_MONGODB_URI
2524 value : mongodb://user-mongo-service:27017/user-service
2625 resources :
26+ requests :
27+ memory : " 32Mi"
28+ cpu : " 0.2"
2729 limits :
28- memory : 512Mi
29- cpu : " 1 "
30+ memory : " 64Mi "
31+ cpu : " 0.4 "
3032---
3133apiVersion : v1
3234kind : Service
3941 - protocol : TCP
4042 port : 8081
4143 targetPort : 8081
42- type : ClusterIP
44+ type : NodePort
Original file line number Diff line number Diff line change 1- package com .programming .streaming ;
1+ package com .programming .userService ;
22
33import org .springframework .boot .SpringApplication ;
44import org .springframework .boot .autoconfigure .SpringBootApplication ;
Original file line number Diff line number Diff line change 1- package com .programming .streaming .config ;
1+ package com .programming .userService .config ;
22
33import org .springframework .context .annotation .Bean ;
44import org .springframework .context .annotation .Configuration ;
Original file line number Diff line number Diff line change @@ -49,11 +49,6 @@ public String getEmail() {
4949 }
5050 }
5151
52- @ GetMapping ("/" )
53- public String getServiceName (){
54- return "User Service" ;
55- }
56-
5752 @ PostMapping ("/send-verification-email" )
5853 public String sendVerificationEmail (@ RequestBody String emailJson ) {
5954 SimpleMailMessage message = new SimpleMailMessage ();
Original file line number Diff line number Diff line change 1- package com .programming .streaming .entity ;
1+ package com .programming .userService .entity ;
22
33import lombok .Builder ;
44import lombok .Data ;
You can’t perform that action at this time.
0 commit comments