File tree 8 files changed +98
-17
lines changed
8 files changed +98
-17
lines changed Original file line number Diff line number Diff line change 1
1
apiVersion : apps/v1
2
2
kind : Deployment
3
3
metadata :
4
- name : spring-boot-deployment
4
+ name : spring-boot-app
5
5
spec :
6
6
replicas : 1
7
7
selector :
18
18
imagePullPolicy : Never
19
19
ports :
20
20
- containerPort : 8080
21
-
22
-
21
+ env :
22
+ - name : SPRING_DATASOURCE_URL
23
+ value : jdbc:postgresql://postgres:5432/mydatabase
24
+ - name : SPRING_DATASOURCE_USERNAME
25
+ value : user
26
+ - name : SPRING_DATASOURCE_PASSWORD
27
+ value : password
Original file line number Diff line number Diff line change 1
1
apiVersion : v1
2
2
kind : Service
3
3
metadata :
4
- name : spring-boot-service
4
+ name : spring-boot-app
5
5
spec :
6
6
type : NodePort
7
- selector :
8
- app : spring-boot-app
9
7
ports :
10
- - protocol : TCP
11
- port : 8080
8
+ - port : 8080
12
9
targetPort : 8080
13
- nodePort : 30007
14
-
15
-
10
+ nodePort : 30001
11
+ selector :
12
+ app : spring-boot-app
Original file line number Diff line number Diff line change @@ -6,4 +6,4 @@ services:
6
6
- ' POSTGRES_PASSWORD=password'
7
7
- ' POSTGRES_USER=user'
8
8
ports :
9
- - ' 5432:5432 '
9
+ - ' 5432'
Original file line number Diff line number Diff line change
1
+ apiVersion : apps/v1
2
+ kind : Deployment
3
+ metadata :
4
+ name : postgres
5
+ spec :
6
+ replicas : 1
7
+ selector :
8
+ matchLabels :
9
+ app : postgres
10
+ template :
11
+ metadata :
12
+ labels :
13
+ app : postgres
14
+ spec :
15
+ containers :
16
+ - name : postgres
17
+ image : postgres:latest
18
+ env :
19
+ - name : POSTGRES_DB
20
+ value : mydatabase
21
+ - name : POSTGRES_PASSWORD
22
+ value : password
23
+ - name : POSTGRES_USER
24
+ value : user
25
+ ports :
26
+ - containerPort : 5432
27
+ volumeMounts :
28
+ - mountPath : /var/lib/postgresql/data
29
+ name : postgres-storage
30
+ volumes :
31
+ - name : postgres-storage
32
+ persistentVolumeClaim :
33
+ claimName : postgres-pvc
Original file line number Diff line number Diff line change
1
+ apiVersion : v1
2
+ kind : Service
3
+ metadata :
4
+ name : postgres
5
+ spec :
6
+ type : NodePort
7
+ ports :
8
+ - port : 5432
9
+ targetPort : 5432
10
+ nodePort : 32432
11
+ selector :
12
+ app : postgres
13
+
14
+
Original file line number Diff line number Diff line change
1
+ apiVersion : v1
2
+ kind : PersistentVolume
3
+ metadata :
4
+ name : postgres-pv
5
+ spec :
6
+ capacity :
7
+ storage : 1Gi
8
+ accessModes :
9
+ - ReadWriteOnce
10
+ hostPath :
11
+ path : /data/postgres
12
+ ---
13
+ apiVersion : v1
14
+ kind : PersistentVolumeClaim
15
+ metadata :
16
+ name : postgres-pvc
17
+ spec :
18
+ accessModes :
19
+ - ReadWriteOnce
20
+ resources :
21
+ requests :
22
+ storage : 1Gi
Original file line number Diff line number Diff line change 1
- spring.application.name =spring-boot-app
1
+ spring.datasource.url =jdbc:postgresql://localhost:5432/mydatabase
2
+ spring.datasource.username =user
3
+ spring.datasource.password =password
4
+ # spring.datasource.driver-class-name=org.postgresql.Driver
5
+
6
+ # Hibernate settings
7
+ spring.jpa.hibernate.ddl-auto =update
8
+ # spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
9
+
10
+ spring.jpa.show-sql =true
11
+ spring.jpa.properties.hibernate.format_sql =true
12
+
13
+ # Initialize database
2
14
spring.sql.init.mode =always
3
- spring.jpa.hibernate.ddl-auto =create
Original file line number Diff line number Diff line change 1
1
DROP TABLE IF EXISTS User; -- don't do this on a production environment
2
2
3
3
CREATE TABLE User (
4
- id varchar ( 255 ) NOT NULL ,
4
+ id SERIAL PRIMARY KEY ,
5
5
name varchar (255 ) NOT NULL ,
6
- email varchar (255 ) NOT NULL ,
7
- PRIMARY KEY (id)
6
+ email varchar (255 ) NOT NULL
8
7
);
9
8
10
9
INSERT INTO User
You can’t perform that action at this time.
0 commit comments