yaml update

This commit is contained in:
lowCost 2025-11-30 19:14:50 +09:00
parent 3eef14eef4
commit b76c0b6671
9 changed files with 148 additions and 137 deletions

4
k8s/00-petclinic-ns.yaml Normal file
View file

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: petclinic-ns

5
k8s/01-petclinic-sa.yaml Normal file
View file

@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: petclinic-sa
namespace: petclinic-ns

View file

@ -0,0 +1,17 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: petclinic-db-config
namespace: petclinic-ns
data:
SPRING_DATASOURCE_URL: "jdbc:postgresql://finalproj-dev-postgres.ctxvni2x7reb.ap-northeast-2.rds.amazonaws.com:5432/petclinic"
SPRING_DATASOURCE_DRIVER_CLASS_NAME: "org.postgresql.Driver"
# Hikari Pool Settings (그대로 사용)
# SPRING_DATASOURCE_HIKARI_MAXIMUM_POOL_SIZE: "20"
# SPRING_DATASOURCE_HIKARI_MINIMUM_IDLE: "5"
# SPRING_DATASOURCE_HIKARI_IDLE_TIMEOUT: "600000"
# SPRING_DATASOURCE_HIKARI_CONNECTION_TIMEOUT: "30000"
# SPRING_DATASOURCE_HIKARI_VALIDATION_TIMEOUT: "5000"

View file

@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: petclinic-db-secret
namespace: petclinic-ns
type: Opaque
stringData:
SPRING_DATASOURCE_USERNAME: "petclinic"
SPRING_DATASOURCE_PASSWORD: "poweradmin!"

View file

@ -0,0 +1,72 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: petclinic
namespace: petclinic-ns
labels:
app: petclinic
spec:
replicas: 2
selector:
matchLabels:
app: petclinic
template:
metadata:
labels:
app: petclinic
spec:
# 🔹 여기: service account 지정
serviceAccountName: petclinic-sa
nodeSelector:
role: "app"
tolerations:
- key: "role"
operator: "Equal"
value: "app"
effect: "NoSchedule"
containers:
- name: petclinic-container
image: insulin90/petclinic:v0.2
# DB 설정은 ConfigMap / Secret에서 그대로 가져오기
envFrom:
- configMapRef:
name: petclinic-db-config
- secretRef:
name: petclinic-db-secret
# 🔹 여기: Spring profile을 postgres용으로
env:
- name: SPRING_PROFILES_ACTIVE
value: "postgres"
ports:
- name: http
containerPort: 8080
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: http
initialDelaySeconds: 60
periodSeconds: 10
failureThreshold: 5
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: http
initialDelaySeconds: 60
periodSeconds: 10
failureThreshold: 5
resources:
requests:
cpu: "250m"
memory: "512Mi"
limits:
cpu: "500m"
memory: "1Gi"

View file

@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: petclinic
namespace: petclinic-ns
spec:
type: ClusterIP
selector:
app: petclinic
ports:
- name: http
port: 80 # 클러스터 내부에서 볼 포트
targetPort: http # 위 컨테이너 포트 이름

View file

@ -0,0 +1,28 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: petclinic
namespace: petclinic-ns
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP":80}]'
# 헬스체크 설정
alb.ingress.kubernetes.io/healthcheck-path: /actuator/health/liveness
alb.ingress.kubernetes.io/healthcheck-port: traffic-port
alb.ingress.kubernetes.io/healthcheck-protocol: HTTP
spec:
ingressClassName: alb
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: petclinic
port:
number: 80

View file

@ -1,73 +0,0 @@
---
apiVersion: v1
kind: Secret
metadata:
name: demo-db
type: servicebinding.io/postgresql
stringData:
type: "postgresql"
provider: "postgresql"
host: "demo-db"
port: "5432"
database: "petclinic"
username: "user"
password: "pass"
---
apiVersion: v1
kind: Service
metadata:
name: demo-db
spec:
ports:
- port: 5432
selector:
app: demo-db
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: demo-db
labels:
app: demo-db
spec:
selector:
matchLabels:
app: demo-db
template:
metadata:
labels:
app: demo-db
spec:
containers:
- image: postgres:18.0
name: postgresql
env:
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: demo-db
key: username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: demo-db
key: password
- name: POSTGRES_DB
valueFrom:
secretKeyRef:
name: demo-db
key: database
ports:
- containerPort: 5432
name: postgresql
livenessProbe:
tcpSocket:
port: postgresql
readinessProbe:
tcpSocket:
port: postgresql
startupProbe:
tcpSocket:
port: postgresql

View file

@ -1,64 +0,0 @@
---
apiVersion: v1
kind: Service
metadata:
name: petclinic
spec:
type: NodePort
ports:
- port: 80
targetPort: 8080
selector:
app: petclinic
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: petclinic
labels:
app: petclinic
spec:
replicas: 1
selector:
matchLabels:
app: petclinic
template:
metadata:
labels:
app: petclinic
spec:
containers:
- name: workload
image: dsyer/petclinic
env:
- name: SPRING_PROFILES_ACTIVE
value: postgres
- name: SERVICE_BINDING_ROOT
value: /bindings
- name: SPRING_APPLICATION_JSON
value: |
{
"management.endpoint.health.probes.add-additional-paths": true
}
ports:
- name: http
containerPort: 8080
livenessProbe:
httpGet:
path: /livez
port: http
readinessProbe:
httpGet:
path: /readyz
port: http
volumeMounts:
- mountPath: /bindings/secret
name: binding
readOnly: true
volumes:
- name: binding
projected:
sources:
- secret:
name: demo-db