Skip to content

Commit

Permalink
[NS-35] - Kubernetes testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Narvane committed Feb 23, 2024
1 parent e042e8f commit a2c5b83
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 6 deletions.
8 changes: 8 additions & 0 deletions api-webmvc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

<properties>
<java.version>17</java.version>
<start-class>com.narvane.apimvc.ApiWebMvcApplication</start-class>
</properties>

<dependencies>
Expand Down Expand Up @@ -78,6 +79,13 @@
</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
12 changes: 6 additions & 6 deletions api-webmvc/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
user: ${POSTGRES_USER}
password: ${POSTGRES_PASSWORD}
13 changes: 13 additions & 0 deletions k8s/app/app-service.yml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions k8s/app/app.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions k8s/db/postgres-secret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: postgres-secret
type: Opaque
data:
POSTGRES_USER: bW9uZ291c2Vy
POSTGRES_PASSWORD: bW9uZ29wYXNzd29yZA==
13 changes: 13 additions & 0 deletions k8s/db/postgres-service.yml
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions k8s/db/postgres.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a2c5b83

Please sign in to comment.