From 23e230e36831b55dd274edebd7c1e6026b1ada57 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 12 Nov 2026 07:33:12 +0900 Subject: [PATCH] =?UTF-8?q?chore(deploy):=20=EC=9A=B4=EC=98=81=20hyeonwork?= =?UTF-8?q?s.com=20=EB=A7=A4=EB=8B=88=ED=8E=98=EC=8A=A4=ED=8A=B8=EB=A5=BC?= =?UTF-8?q?=20=EC=A7=80=EA=B8=88=20=EC=83=81=ED=83=9C=20=EA=B7=B8=EB=8C=80?= =?UTF-8?q?=EB=A1=9C=20=EA=B8=B0=EB=A1=9D=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hyeonworks-prod의 앱 객체는 kubectl apply로만 들어가 있고 어느 repo에도 정본이 없다. 그래서 무엇이 운영에 떠 있는지 Git으로 볼 수 없고, 이미지나 설정을 바꿀 때 기준이 되는 파일도 없다. live 객체 16개를 deploy/production에 그대로 옮긴다. backend·frontend·redis Deployment, Service 넷, ServiceMonitor, logging ConfigMap, Ingress, NetworkPolicy 여섯이다. 각 객체의 last-applied 설정을 쓰고, 서버가 채우는 칸(uid, resourceVersion, status, clusterIP 등)은 뺐다. 정본 위치는 소유자 결정(2026-11-11, 「앱 쪽은 tech-log repo deploy/」)을 따른다. Namespace, techlog DB Role·Database, 다른 namespace의 NetworkPolicy·Probe· 규칙은 platform-core services/tenants/techlog가 맡는다. hyeonworks-secrets Secret은 Git에 두지 않는다. 위험·한계: 동작은 바뀌지 않는다. 운영 source commit(frontend 7a4e201, backend 46b1cc7)은 아직 Gitea에 없어서, 이 파일들이 가리키는 이미지를 이 repo의 main에서 다시 만들 수는 없다. 검증: kubectl kustomize deploy/production을 live 클러스터에 대고 kubectl diff를 돌렸다. 16개 객체 모두 차이가 0줄이다. 값을 하나씩 보고 비밀 값은 secretKeyRef 참조뿐인 것을 확인했다. --- deploy/production/backend-deployment.yaml | 178 ++++++++++++++++++ .../production/backend-logging-configmap.yaml | 81 ++++++++ deploy/production/backend-servicemonitor.yaml | 19 ++ deploy/production/backend-services.yaml | 29 +++ deploy/production/frontend-deployment.yaml | 63 +++++++ deploy/production/frontend-service.yaml | 13 ++ deploy/production/ingress.yaml | 47 +++++ deploy/production/kustomization.yaml | 21 +++ deploy/production/network-policies.yaml | 161 ++++++++++++++++ deploy/production/redis-deployment.yaml | 66 +++++++ deploy/production/redis-service.yaml | 13 ++ 11 files changed, 691 insertions(+) create mode 100644 deploy/production/backend-deployment.yaml create mode 100644 deploy/production/backend-logging-configmap.yaml create mode 100644 deploy/production/backend-servicemonitor.yaml create mode 100644 deploy/production/backend-services.yaml create mode 100644 deploy/production/frontend-deployment.yaml create mode 100644 deploy/production/frontend-service.yaml create mode 100644 deploy/production/ingress.yaml create mode 100644 deploy/production/kustomization.yaml create mode 100644 deploy/production/network-policies.yaml create mode 100644 deploy/production/redis-deployment.yaml create mode 100644 deploy/production/redis-service.yaml diff --git a/deploy/production/backend-deployment.yaml b/deploy/production/backend-deployment.yaml new file mode 100644 index 0000000..dde0160 --- /dev/null +++ b/deploy/production/backend-deployment.yaml @@ -0,0 +1,178 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: techlog-backend +spec: + progressDeadlineSeconds: 600 + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + app: techlog-backend + strategy: + type: Recreate + template: + metadata: + labels: + app: techlog-backend + spec: + automountServiceAccountToken: false + containers: + - env: + - name: SPRING_PROFILES_ACTIVE + value: local + - name: SPRING_DATASOURCE_URL + value: jdbc:postgresql://platform-postgres-rw.platform-data.svc.cluster.local:5432/techlog + - name: SPRING_DATASOURCE_USERNAME + value: techlog + - name: SPRING_DATASOURCE_PASSWORD + valueFrom: + secretKeyRef: + key: APP_DB_PASSWORD + name: hyeonworks-secrets + - name: SPRING_DATASOURCE_DRIVER_CLASS_NAME + value: org.postgresql.Driver + - name: SPRING_FLYWAY_ENABLED + value: 'true' + - name: SPRING_JPA_HIBERNATE_DDL_AUTO + value: none + - name: CA_SKELETON_PERSISTENCE_VENDOR + value: postgresql + - name: CA_SKELETON_SECURITY_AUTH_MODE + value: redis-session + - name: CA_SKELETON_SECURITY_SESSION_COOKIE_NAME + value: TECHLOG_SESSION + - name: CA_SKELETON_SECURITY_SESSION_PATH + value: / + - name: CA_SKELETON_SECURITY_SESSION_SECURE + value: 'true' + - name: CA_SKELETON_SECURITY_SESSION_SAME_SITE + value: Lax + - name: APP_REDIS_ENABLED + value: 'true' + - name: APP_REDIS_AUTHENTICATION_ANONYMOUS_ACCESS_ACCEPTED + value: 'true' + - name: SPRING_DATA_REDIS_HOST + value: redis + - name: SPRING_DATA_REDIS_PORT + value: '6379' + - name: SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_KEYCLOAK_ISSUER_URI + value: https://id.learn.hyeonworks.com/realms/prod + - name: SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_KEYCLOAK_CLIENT_ID + value: tech-log-bff + - name: SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_KEYCLOAK_CLIENT_SECRET + valueFrom: + secretKeyRef: + key: TECHLOG_OIDC_CLIENT_SECRET + name: hyeonworks-secrets + - name: SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_KEYCLOAK_SCOPE + value: openid,profile,email + - name: SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_KEYCLOAK_AUTHORIZATION_GRANT_TYPE + value: authorization_code + - name: SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_KEYCLOAK_REDIRECT_URI + value: https://hyeonworks.com/login/oauth2/code/keycloak + - name: APP_STUDIO_AUTHOR_ROLE + value: site-admin + - name: APP_SESSION_TIMEOUT + value: 24h + - name: APP_STUDIO_POST_LOGIN_REDIRECT + value: https://hyeonworks.com/studio + - name: APP_SERVER_FORWARD_HEADERS_STRATEGY + value: framework + - name: CA_SKELETON_CORS_ALLOWED_ORIGINS + value: https://hyeonworks.com + - name: CA_SKELETON_OBJECTSTORAGE_BACKEND + value: s3 + - name: CA_SKELETON_OBJECTSTORAGE_ENDPOINT + value: http://minio.object-storage.svc.cluster.local + - name: CA_SKELETON_OBJECTSTORAGE_REGION + value: us-east-1 + - name: CA_SKELETON_OBJECTSTORAGE_PATH_STYLE_ACCESS + value: 'true' + - name: CA_SKELETON_OBJECTSTORAGE_AUTO_CREATE_BUCKET + value: 'false' + - name: CA_SKELETON_OBJECTSTORAGE_BUCKET + valueFrom: + secretKeyRef: + key: S3_BUCKET + name: hyeonworks-secrets + - name: CA_SKELETON_OBJECTSTORAGE_ACCESS_KEY + valueFrom: + secretKeyRef: + key: S3_ACCESS_KEY + name: hyeonworks-secrets + - name: CA_SKELETON_OBJECTSTORAGE_SECRET_KEY + valueFrom: + secretKeyRef: + key: S3_SECRET_KEY + name: hyeonworks-secrets + - name: TZ + value: UTC + - name: MANAGEMENT_ENDPOINT_HEALTH_SHOW_COMPONENTS + value: always + - name: LOGGING_CONFIG + value: /etc/techlog-logging/logback-spring.xml + - name: APP_TRACING_SAMPLE_RATE + value: '0.1' + - name: APP_LOG_LEVEL_APP + value: INFO + - name: APP_LOG_LEVEL_ROOT + value: INFO + - name: APP_REDIS_NODES + value: redis.hyeonworks-prod.svc.cluster.local:6379 + - name: APP_TRACING_ENABLED + value: 'true' + image: tech-log-backend:46b1cc7 + imagePullPolicy: Never + livenessProbe: + failureThreshold: 3 + httpGet: + path: /actuator/health/liveness + port: management + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 3 + name: backend + ports: + - containerPort: 8080 + name: http + protocol: TCP + - containerPort: 9001 + name: management + protocol: TCP + readinessProbe: + failureThreshold: 6 + httpGet: + path: /actuator/health/readiness + port: management + initialDelaySeconds: 15 + periodSeconds: 5 + timeoutSeconds: 3 + resources: + limits: + memory: 1536Mi + requests: + cpu: 200m + memory: 512Mi + startupProbe: + failureThreshold: 36 + httpGet: + path: /actuator/health/startup + port: management + periodSeconds: 5 + timeoutSeconds: 3 + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /etc/techlog-logging + name: logging-config + readOnly: true + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 + volumes: + - configMap: + name: techlog-logging + name: logging-config diff --git a/deploy/production/backend-logging-configmap.yaml b/deploy/production/backend-logging-configmap.yaml new file mode 100644 index 0000000..86719fc --- /dev/null +++ b/deploy/production/backend-logging-configmap.yaml @@ -0,0 +1,81 @@ +apiVersion: v1 +data: + logback-spring.xml: "\n \n\n \n \n \n\n \n \n \n \n \n\n \n \n\ + \ \n\n \n \n \ + \ \n \n\n \n \n\n\ + \ \n \n\n \n \n \ + \ ${LOG_SAMPLING_RATE}\n \n \n\n \n\n \n \n \n false\n\ + \ {\"app\":\"${APP_NAME}\",\"profile\":\"${APP_PROFILE}\"}\n\ + \ trace_id\n span_id\n\ + \ request_id\n correlation_id\n\ + \ user_principal\n ${JSON_TIMEZONE}\n\ + \ ${JSON_TIMESTAMP_PATTERN}\n ${JSON_INCLUDE_CALLER_DATA}\n\ + \ ${JSON_LOGGER_NAME_LENGTH}\n\ + \ \n \n \n \n FILE_ENABLEDtrue\n \n \n \n\ + \ \n ${FILE_PATH}\n \n ${FILE_PATH}.%d{yyyy-MM-dd}.%i.gz\n \ + \ ${FILE_MAX_SIZE}\n ${FILE_MAX_HISTORY}\n\ + \ ${FILE_TOTAL_SIZE_CAP}\n \n\ + \ \n \ + \ false\n {\"app\":\"${APP_NAME}\"\ + ,\"profile\":\"${APP_PROFILE}\"}\n trace_id\n\ + \ span_id\n request_id\n\ + \ correlation_id\n user_principal\n\ + \ ${JSON_TIMEZONE}\n ${JSON_TIMESTAMP_PATTERN}\n\ + \ ${JSON_INCLUDE_CALLER_DATA}\n \ + \ ${JSON_LOGGER_NAME_LENGTH}\n \ + \ \n \n \n \n \n\n \n\n\ + \ \n ASYNC_ENABLEDtrue\n\ + \ \n \n \n \n ${ASYNC_QUEUE_SIZE}\n\ + \ ${ASYNC_DISCARDING_THRESHOLD}\n \ + \ false\n \n \ + \ \n \n FILE_ENABLEDtrue\n \n \ + \ \n \n \n ${ASYNC_QUEUE_SIZE}\n ${ASYNC_DISCARDING_THRESHOLD}\n\ + \ false\n \n \n \n \n \ + \ \n \n\n \n\n \n \n ASYNC_ENABLEDtrue\n \n \n \n\ + \ \n \ + \ FILE_ENABLEDtrue\n \n \n\ + \ \n \n \n \n \ + \ \n \n \n \n \n \n\ + \ \n \n \n \n \n FILE_ENABLEDtrue\n\ + \ \n \n \n \n \n \n \n \n \n\ + \ \n \n \n \n \n \n \ + \ \n" +kind: ConfigMap +metadata: + name: techlog-logging diff --git a/deploy/production/backend-servicemonitor.yaml b/deploy/production/backend-servicemonitor.yaml new file mode 100644 index 0000000..c3e8405 --- /dev/null +++ b/deploy/production/backend-servicemonitor.yaml @@ -0,0 +1,19 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + labels: + observability.hyeonworks.com/instance: home + name: techlog-backend +spec: + endpoints: + - interval: 30s + path: /actuator/prometheus + port: management + relabelings: + - replacement: techlog + targetLabel: application + scrapeTimeout: 10s + selector: + matchLabels: + app: techlog-backend + component: management diff --git a/deploy/production/backend-services.yaml b/deploy/production/backend-services.yaml new file mode 100644 index 0000000..1b42d84 --- /dev/null +++ b/deploy/production/backend-services.yaml @@ -0,0 +1,29 @@ +apiVersion: v1 +kind: Service +metadata: + name: techlog-backend +spec: + ports: + - name: http + port: 8080 + protocol: TCP + targetPort: 8080 + selector: + app: techlog-backend + type: ClusterIP +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: techlog-backend + component: management + name: techlog-management +spec: + ports: + - name: management + port: 9001 + targetPort: management + selector: + app: techlog-backend + type: ClusterIP diff --git a/deploy/production/frontend-deployment.yaml b/deploy/production/frontend-deployment.yaml new file mode 100644 index 0000000..0848864 --- /dev/null +++ b/deploy/production/frontend-deployment.yaml @@ -0,0 +1,63 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: techlog-frontend +spec: + progressDeadlineSeconds: 600 + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + app: techlog-frontend + strategy: + rollingUpdate: + maxSurge: 25% + maxUnavailable: 25% + type: RollingUpdate + template: + metadata: + labels: + app: techlog-frontend + spec: + automountServiceAccountToken: false + containers: + - image: docker.io/library/tech-log-frontend:7a4e201 + imagePullPolicy: Never + livenessProbe: + failureThreshold: 3 + httpGet: + path: /config.json + port: 80 + scheme: HTTP + initialDelaySeconds: 15 + periodSeconds: 20 + successThreshold: 1 + timeoutSeconds: 1 + name: frontend + ports: + - containerPort: 80 + name: http + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + path: /config.json + port: 80 + scheme: HTTP + initialDelaySeconds: 3 + periodSeconds: 5 + successThreshold: 1 + timeoutSeconds: 1 + resources: + limits: + memory: 128Mi + requests: + cpu: 20m + memory: 32Mi + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 diff --git a/deploy/production/frontend-service.yaml b/deploy/production/frontend-service.yaml new file mode 100644 index 0000000..582ec48 --- /dev/null +++ b/deploy/production/frontend-service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: techlog-frontend +spec: + ports: + - name: http + port: 80 + protocol: TCP + targetPort: 80 + selector: + app: techlog-frontend + type: ClusterIP diff --git a/deploy/production/ingress.yaml b/deploy/production/ingress.yaml new file mode 100644 index 0000000..40d3335 --- /dev/null +++ b/deploy/production/ingress.yaml @@ -0,0 +1,47 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + traefik.ingress.kubernetes.io/router.entrypoints: web + name: hyeonworks-core +spec: + ingressClassName: traefik + rules: + - host: hyeonworks.com + http: + paths: + - backend: + service: + name: techlog-backend + port: + number: 8080 + path: /api + pathType: Prefix + - backend: + service: + name: techlog-backend + port: + number: 8080 + path: /oauth2 + pathType: Prefix + - backend: + service: + name: techlog-backend + port: + number: 8080 + path: /login + pathType: Prefix + - backend: + service: + name: techlog-backend + port: + number: 8080 + path: /logout + pathType: Prefix + - backend: + service: + name: techlog-frontend + port: + number: 80 + path: / + pathType: Prefix diff --git a/deploy/production/kustomization.yaml b/deploy/production/kustomization.yaml new file mode 100644 index 0000000..ca6e265 --- /dev/null +++ b/deploy/production/kustomization.yaml @@ -0,0 +1,21 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +# Application side of hyeonworks.com in the hyeonworks-prod namespace. +# The Namespace, the techlog database role and database, and the +# NetworkPolicies, Probes and rules in platform namespaces belong to +# platform-core services/tenants/techlog. The hyeonworks-secrets Secret is +# created outside Git. +namespace: hyeonworks-prod + +resources: + - backend-logging-configmap.yaml + - backend-deployment.yaml + - backend-services.yaml + - backend-servicemonitor.yaml + - redis-deployment.yaml + - redis-service.yaml + - frontend-deployment.yaml + - frontend-service.yaml + - ingress.yaml + - network-policies.yaml diff --git a/deploy/production/network-policies.yaml b/deploy/production/network-policies.yaml new file mode 100644 index 0000000..a464ec4 --- /dev/null +++ b/deploy/production/network-policies.yaml @@ -0,0 +1,161 @@ +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: techlog-backend-egress +spec: + egress: + - ports: + - port: 5432 + protocol: TCP + to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: platform-data + podSelector: + matchLabels: + cnpg.io/cluster: platform-postgres + - ports: + - port: 9000 + protocol: TCP + to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: object-storage + podSelector: + matchLabels: + aistor.min.io/objectStore: minio-aistor + - ports: + - port: 6379 + protocol: TCP + to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: hyeonworks-prod + podSelector: + matchLabels: + app: redis + - ports: + - port: 443 + protocol: TCP + to: + - ipBlock: + cidr: 192.168.0.107/32 + podSelector: + matchLabels: + app: techlog-backend + policyTypes: + - Egress +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: techlog-backend-ingress +spec: + ingress: + - from: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: kube-system + podSelector: + matchLabels: + app.kubernetes.io/name: traefik + ports: + - port: 8080 + protocol: TCP + - from: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: observability + podSelector: + matchLabels: + app.kubernetes.io/name: prometheus + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: observability + podSelector: + matchLabels: + app.kubernetes.io/name: prometheus-blackbox-exporter + ports: + - port: 9001 + protocol: TCP + podSelector: + matchLabels: + app: techlog-backend + policyTypes: + - Ingress +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: techlog-default-deny +spec: + podSelector: {} + policyTypes: + - Ingress + - Egress +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: techlog-dns-egress +spec: + egress: + - ports: + - port: 53 + protocol: UDP + - port: 53 + protocol: TCP + to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: kube-system + podSelector: + matchLabels: + k8s-app: kube-dns + podSelector: {} + policyTypes: + - Egress +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: techlog-frontend-ingress +spec: + ingress: + - from: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: kube-system + podSelector: + matchLabels: + app.kubernetes.io/name: traefik + ports: + - port: 80 + protocol: TCP + podSelector: + matchLabels: + app: techlog-frontend + policyTypes: + - Ingress +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: techlog-redis-ingress +spec: + ingress: + - from: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: hyeonworks-prod + podSelector: + matchLabels: + app: techlog-backend + ports: + - port: 6379 + protocol: TCP + podSelector: + matchLabels: + app: redis + policyTypes: + - Ingress diff --git a/deploy/production/redis-deployment.yaml b/deploy/production/redis-deployment.yaml new file mode 100644 index 0000000..784c0c0 --- /dev/null +++ b/deploy/production/redis-deployment.yaml @@ -0,0 +1,66 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: redis +spec: + progressDeadlineSeconds: 600 + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + app: redis + strategy: + type: Recreate + template: + metadata: + labels: + app: redis + spec: + automountServiceAccountToken: false + containers: + - args: + - redis-server + - --save + - '' + - --appendonly + - 'no' + image: redis:7-alpine + imagePullPolicy: IfNotPresent + livenessProbe: + exec: + command: + - redis-cli + - ping + failureThreshold: 3 + initialDelaySeconds: 20 + periodSeconds: 15 + successThreshold: 1 + timeoutSeconds: 1 + name: redis + ports: + - containerPort: 6379 + name: redis + protocol: TCP + readinessProbe: + exec: + command: + - redis-cli + - ping + failureThreshold: 3 + initialDelaySeconds: 5 + periodSeconds: 5 + successThreshold: 1 + timeoutSeconds: 1 + resources: + limits: + memory: 256Mi + requests: + cpu: 50m + memory: 64Mi + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 diff --git a/deploy/production/redis-service.yaml b/deploy/production/redis-service.yaml new file mode 100644 index 0000000..985f590 --- /dev/null +++ b/deploy/production/redis-service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: redis +spec: + ports: + - name: redis + port: 6379 + protocol: TCP + targetPort: 6379 + selector: + app: redis + type: ClusterIP