diff --git a/api-webmvc/pom.xml b/api-webmvc/pom.xml
index 2e6ea31..95ead5c 100644
--- a/api-webmvc/pom.xml
+++ b/api-webmvc/pom.xml
@@ -16,6 +16,7 @@
17
+ com.narvane.apimvc.ApiWebMvcApplication
@@ -78,6 +79,13 @@
+
+
+
+ repackage
+
+
+
diff --git a/api-webmvc/src/main/resources/application-prod.yml b/api-webmvc/src/main/resources/application-prod.yml
index a6db409..94335d4 100644
--- a/api-webmvc/src/main/resources/application-prod.yml
+++ b/api-webmvc/src/main/resources/application-prod.yml
@@ -7,16 +7,16 @@ spring:
basename: messages
encoding: UTF-8
datasource:
- url: jdbc:postgresql://localhost:5432/my-storage
- username: root
- password: root
+ url: jdbc:postgresql://postgres-service:5432/my-storage
+ username: ${POSTGRES_USER}
+ password: ${POSTGRES_PASSWORD}
jpa:
database-platform: org.hibernate.dialect.PostgreSQLDialect
hibernate:
ddl-auto: validate
show-sql: true
flyway:
- url: jdbc:postgresql://localhost:5432/my-storage
+ url: jdbc:postgresql://postgres-service:5432/my-storage
locations: filesystem:migrations/src/main/resources/migration
- user: root
- password: root
\ No newline at end of file
+ user: ${POSTGRES_USER}
+ password: ${POSTGRES_PASSWORD}
\ No newline at end of file
diff --git a/k8s/app/app-service.yml b/k8s/app/app-service.yml
new file mode 100644
index 0000000..2c641fd
--- /dev/null
+++ b/k8s/app/app-service.yml
@@ -0,0 +1,13 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: my-storage-service
+spec:
+ type: NodePort
+ selector:
+ app: my-storage
+ ports:
+ - protocol: TCP
+ port: 3000
+ targetPort: 3000
+ nodePort: 30100
\ No newline at end of file
diff --git a/k8s/app/app.yml b/k8s/app/app.yml
new file mode 100644
index 0000000..9b1389e
--- /dev/null
+++ b/k8s/app/app.yml
@@ -0,0 +1,34 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: my-storage
+ labels:
+ app: my-storage
+spec:
+ replicas: 2
+ selector:
+ matchLabels:
+ app: my-storage
+ template:
+ metadata:
+ labels:
+ app: my-storage
+ spec:
+ containers:
+ - name: my-storage
+ image: ghcr.io/narvane/my-storage/my-storage-image:v0.1.3
+ ports:
+ - containerPort: 8081
+ env:
+ - name: SPRING_PROFILES_ACTIVE
+ value: prod
+ - name: POSTGRES_USER
+ valueFrom:
+ secretKeyRef:
+ name: postgres-secret
+ key: POSTGRES_USER
+ - name: POSTGRES_PASSWORD
+ valueFrom:
+ secretKeyRef:
+ name: postgres-secret
+ key: POSTGRES_PASSWORD
\ No newline at end of file
diff --git a/k8s/db/postgres-secret.yml b/k8s/db/postgres-secret.yml
new file mode 100644
index 0000000..454c258
--- /dev/null
+++ b/k8s/db/postgres-secret.yml
@@ -0,0 +1,8 @@
+apiVersion: v1
+kind: Secret
+metadata:
+ name: postgres-secret
+type: Opaque
+data:
+ POSTGRES_USER: bW9uZ291c2Vy
+ POSTGRES_PASSWORD: bW9uZ29wYXNzd29yZA==
diff --git a/k8s/db/postgres-service.yml b/k8s/db/postgres-service.yml
new file mode 100644
index 0000000..76c8f50
--- /dev/null
+++ b/k8s/db/postgres-service.yml
@@ -0,0 +1,13 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: postgres-service
+ labels:
+ app: postgres-service
+spec:
+ ports:
+ - protocol: TCP
+ name: postgres-service
+ port: 5432
+ selector:
+ app: postgres
\ No newline at end of file
diff --git a/k8s/db/postgres.yml b/k8s/db/postgres.yml
new file mode 100644
index 0000000..92a2a2e
--- /dev/null
+++ b/k8s/db/postgres.yml
@@ -0,0 +1,43 @@
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+ name: postgres
+spec:
+ selector:
+ matchLabels:
+ app: postgres
+ serviceName: postgres
+ replicas: 2
+ template:
+ metadata:
+ labels:
+ app: postgres
+ spec:
+ containers:
+ - name: postgres
+ image: postgres:latest
+ env:
+ - name: POSTGRES_USER
+ valueFrom:
+ secretKeyRef:
+ name: postgres-secret
+ key: POSTGRES_USER
+ - name: POSTGRES_PASSWORD
+ valueFrom:
+ secretKeyRef:
+ name: postgres-secret
+ key: POSTGRES_PASSWORD
+ ports:
+ - name: postgres
+ containerPort: 5432
+ volumeMounts:
+ - name: data
+ mountPath: /var/lib/postgresql/data
+ volumeClaimTemplates:
+ - metadata:
+ name: data
+ spec:
+ accessModes: ["ReadWriteOnce"]
+ resources:
+ requests:
+ storage: 1Gi
\ No newline at end of file