Skip to content

Commit 818c113

Browse files
Merge pull request #1 from giri-jeedigunta/gcp-deployment
GCP Deployment scripts
2 parents 297e268 + 9249e82 commit 818c113

File tree

5 files changed

+118
-2
lines changed

5 files changed

+118
-2
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: app-deployment
5+
labels:
6+
name: app-deployment
7+
app: rest-app-java
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
name: app-pod
13+
app: rest-app-java
14+
template:
15+
metadata:
16+
name: app-pod
17+
labels:
18+
name: app-pod
19+
app: rest-app-java
20+
spec:
21+
containers:
22+
- name: rest-app-java
23+
image: girijeedigunta/rest-app-java:latest
24+
ports:
25+
- containerPort: 4000
26+
---
27+
apiVersion: v1
28+
kind: Service
29+
metadata:
30+
name: app-service
31+
labels:
32+
name: app-service
33+
app: rest-app-java
34+
spec:
35+
selector:
36+
name: app-pod
37+
app: rest-app-java
38+
type: NodePort
39+
ports:
40+
- targetPort: 4000
41+
port: 4000
42+
nodePort: 30004
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
apiVersion: v1
2+
data:
3+
createuser.sh: |-
4+
mongo <<EOF
5+
use api
6+
db.createUser({
7+
user: "giri",
8+
pwd: "spring2020",
9+
roles:[
10+
{role: "dbAdmin", db:"api"}
11+
]
12+
})
13+
EOF
14+
kind: ConfigMap
15+
metadata:
16+
name: mongo-initdb
17+
---
18+
apiVersion: apps/v1
19+
kind: Deployment
20+
metadata:
21+
name: db-deployment
22+
labels:
23+
name: db-deployment
24+
app: rest-app-java
25+
spec:
26+
replicas: 1
27+
selector:
28+
matchLabels:
29+
name: db-pod
30+
app: rest-app-java
31+
template:
32+
metadata:
33+
name: db-pod
34+
labels:
35+
name: db-pod
36+
app: rest-app-java
37+
spec:
38+
containers:
39+
- image: mongo:3.2
40+
name: db
41+
ports:
42+
- containerPort: 27017
43+
volumeMounts:
44+
- name: mongo-initdb
45+
mountPath: /docker-entrypoint-initdb.d
46+
volumes:
47+
- name: mongo-initdb
48+
configMap:
49+
name: mongo-initdb
50+
---
51+
apiVersion: v1
52+
kind: Service
53+
metadata:
54+
name: db
55+
labels:
56+
name: db-service
57+
app: rest-app-java
58+
spec:
59+
selector:
60+
name: db-pod
61+
app: rest-app-java
62+
ports:
63+
- targetPort: 27017
64+
port: 27017

init-mongo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ db.createUser({
22
user: "giri",
33
pwd: "spring2020",
44
roles:[
5-
{role: "dbAdmin", db:"springContacts"}
5+
{role: "dbAdmin", db:"api"}
66
]
77
})

src/main/java/com/restful/services/springReactiveRESTApp/Application.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.restful.services.springReactiveRESTApp;
22

3+
import lombok.extern.slf4j.Slf4j;
34
import org.springframework.boot.SpringApplication;
45
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
import org.springframework.context.ApplicationContext;
57
import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRepositories;
68
/*
79
Author: Giri Jeedigunta
@@ -10,7 +12,15 @@
1012

1113
@SpringBootApplication
1214
@EnableReactiveMongoRepositories
15+
@Slf4j
1316
public class Application {
17+
private final ApplicationContext context;
18+
19+
public Application(ApplicationContext context) {
20+
this.context = context;
21+
log.info("Mongo URI -> {}", context.getEnvironment().getProperty("spring.data.mongodb.uri"));
22+
}
23+
1424
public static void main(String[] args) {
1525
SpringApplication.run(Application.class, args);
1626
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
server.port=4000
2-
spring.data.mongodb.uri=mongodb://giri:spring2020@db:27017/springContacts?authSource=admin
2+
spring.data.mongodb.uri=mongodb://giri:spring2020@db:27017/api?authSource=api&&authMechanism=SCRAM-SHA-1

0 commit comments

Comments
 (0)