Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

refactor: add k8s script and use updated image #40

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ services:
- database
build: .
environment:
SPRING_PROFILES_ACTIVE: "dev-docker"
DB_URL: "jdbc:postgresql://database:5432/fastfood"
SPRING_PROFILES_ACTIVE: "dev"
ports:
- "8080:8080"
networks:
Expand Down
4 changes: 2 additions & 2 deletions k8s/api-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ spec:
containers:
- name: app
env:
- name: DATABASE_URL
- name: DB_URL
value: "jdbc:postgresql://postgres-svc:5432/fastfood"
- name: SPRING_PROFILES_ACTIVE
value: "dev"
image: otaviodocker/api-fastfood:latest
image: fiap7soat30/fast-food:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
Expand Down
18 changes: 18 additions & 0 deletions scripts/deploy-k8s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# metric server
kubectl apply -f ./k8s/metrics.yaml

# database
kubectl create configmap cm-init --from-file=init.sql
kubectl apply -f ./k8s/configmap.yaml
kubectl apply -f ./k8s/postgres-pv.yaml
kubectl apply -f ./k8s/postgres-pvc.yaml
kubectl apply -f ./k8s/postgres-svc.yaml
kubectl apply -f ./k8s/postgres-deployment.yaml

# application
kubectl apply -f ./k8s/api-svc.yaml
kubectl apply -f ./k8s/api-hpa.yaml
kubectl apply -f ./k8s/api-deployment.yaml

# application port forward (temp)
# kubectl port-forward -n default service/api-svc 30007:80
22 changes: 0 additions & 22 deletions src/main/resources/application-dev-docker.properties

This file was deleted.

6 changes: 3 additions & 3 deletions src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# DATASOURCE
spring.datasource.url=jdbc:postgresql://postgres-svc:5432/fastfood
spring.datasource.username=postgres
spring.datasource.password=123456
spring.datasource.url=${DB_URL:jdbc:postgresql://localhost:5432/fastfood}
spring.datasource.username=${DB_USERNAME:postgres}
spring.datasource.password=${DB_PASSWORD:123456}

# JPA, SQL
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
Expand Down
Loading