From b76c0b66711f822da1c8b5053446d58397c39832 Mon Sep 17 00:00:00 2001 From: lowCost Date: Sun, 30 Nov 2025 19:14:50 +0900 Subject: [PATCH] yaml update --- k8s/00-petclinic-ns.yaml | 4 ++ k8s/01-petclinic-sa.yaml | 5 ++ k8s/10-petclinic-configMap.yaml | 17 ++++++ k8s/11-petclinic-secret.yaml | 9 +++ k8s/20-petclinic-Deployments-postgre.yaml | 72 ++++++++++++++++++++++ k8s/30-petclinic-service.yaml | 13 ++++ k8s/31-petclinic-ingress.yaml | 28 +++++++++ k8s/db.yml | 73 ----------------------- k8s/petclinic.yml | 64 -------------------- 9 files changed, 148 insertions(+), 137 deletions(-) create mode 100644 k8s/00-petclinic-ns.yaml create mode 100644 k8s/01-petclinic-sa.yaml create mode 100644 k8s/10-petclinic-configMap.yaml create mode 100644 k8s/11-petclinic-secret.yaml create mode 100644 k8s/20-petclinic-Deployments-postgre.yaml create mode 100644 k8s/30-petclinic-service.yaml create mode 100644 k8s/31-petclinic-ingress.yaml delete mode 100644 k8s/db.yml delete mode 100644 k8s/petclinic.yml diff --git a/k8s/00-petclinic-ns.yaml b/k8s/00-petclinic-ns.yaml new file mode 100644 index 000000000..47836737a --- /dev/null +++ b/k8s/00-petclinic-ns.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: petclinic-ns diff --git a/k8s/01-petclinic-sa.yaml b/k8s/01-petclinic-sa.yaml new file mode 100644 index 000000000..90ad00211 --- /dev/null +++ b/k8s/01-petclinic-sa.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: petclinic-sa + namespace: petclinic-ns \ No newline at end of file diff --git a/k8s/10-petclinic-configMap.yaml b/k8s/10-petclinic-configMap.yaml new file mode 100644 index 000000000..010bd6652 --- /dev/null +++ b/k8s/10-petclinic-configMap.yaml @@ -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" diff --git a/k8s/11-petclinic-secret.yaml b/k8s/11-petclinic-secret.yaml new file mode 100644 index 000000000..beee2e156 --- /dev/null +++ b/k8s/11-petclinic-secret.yaml @@ -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!" diff --git a/k8s/20-petclinic-Deployments-postgre.yaml b/k8s/20-petclinic-Deployments-postgre.yaml new file mode 100644 index 000000000..e68098b19 --- /dev/null +++ b/k8s/20-petclinic-Deployments-postgre.yaml @@ -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" diff --git a/k8s/30-petclinic-service.yaml b/k8s/30-petclinic-service.yaml new file mode 100644 index 000000000..daa08a51b --- /dev/null +++ b/k8s/30-petclinic-service.yaml @@ -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 # 위 컨테이너 포트 이름 diff --git a/k8s/31-petclinic-ingress.yaml b/k8s/31-petclinic-ingress.yaml new file mode 100644 index 000000000..b81bceaa2 --- /dev/null +++ b/k8s/31-petclinic-ingress.yaml @@ -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 diff --git a/k8s/db.yml b/k8s/db.yml deleted file mode 100644 index c2c63037a..000000000 --- a/k8s/db.yml +++ /dev/null @@ -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 diff --git a/k8s/petclinic.yml b/k8s/petclinic.yml deleted file mode 100644 index a5677cd06..000000000 --- a/k8s/petclinic.yml +++ /dev/null @@ -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