Skip to content

Commit 3ba7b48

Browse files
committed
2 parents 2fcf34f + 7240001 commit 3ba7b48

File tree

15 files changed

+127
-43
lines changed

15 files changed

+127
-43
lines changed
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
21
name: Continuous Deployment for User Service
32

43
on:
5-
push:
6-
branches:
7-
- main
4+
workflow_run:
5+
workflows: ["Continuous Integration for Comment Service"]
6+
types:
7+
- completed
88

99
env:
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}}

.github/workflows/notifyCD.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
uses: slackapi/[email protected]
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+
uses: slackapi/[email protected]
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 }}

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ FROM openjdk:17-jdk
33
WORKDIR /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
1212
EXPOSE 8080

database.yaml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,44 @@ spec:
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
---
2863
apiVersion: v1
2964
kind: Service
@@ -35,5 +70,4 @@ spec:
3570
ports:
3671
- protocol: TCP
3772
port: 27017
38-
targetPort: 27017
39-
73+
targetPort: 27017

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
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>

resources.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
apiVersion: apps/v1
32
kind: Deployment
43
metadata:
@@ -24,9 +23,12 @@ spec:
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
---
3133
apiVersion: v1
3234
kind: Service
@@ -39,4 +41,4 @@ spec:
3941
- protocol: TCP
4042
port: 8081
4143
targetPort: 8081
42-
type: ClusterIP
44+
type: NodePort

src/main/java/com/programming/streaming/StreamingApplication.java renamed to src/main/java/com/programming/userService/StreamingApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.programming.streaming;
1+
package com.programming.userService;
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;

src/main/java/com/programming/streaming/config/SecurityConfig.java renamed to src/main/java/com/programming/userService/config/SecurityConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.programming.streaming.config;
1+
package com.programming.userService.config;
22

33
import org.springframework.context.annotation.Bean;
44
import org.springframework.context.annotation.Configuration;

src/main/java/com/programming/streaming/controller/UserController.java renamed to src/main/java/com/programming/userService/controller/UserController.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff 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();

src/main/java/com/programming/streaming/entity/AuthUser.java renamed to src/main/java/com/programming/userService/entity/AuthUser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.programming.streaming.entity;
1+
package com.programming.userService.entity;
22

33
import lombok.Builder;
44
import lombok.Data;

0 commit comments

Comments
 (0)