From 23e230e36831b55dd274edebd7c1e6026b1ada57 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 12 Nov 2026 07:33:12 +0900 Subject: [PATCH 1/2] =?UTF-8?q?chore(deploy):=20=EC=9A=B4=EC=98=81=20hyeon?= =?UTF-8?q?works.com=20=EB=A7=A4=EB=8B=88=ED=8E=98=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EB=A5=BC=20=EC=A7=80=EA=B8=88=20=EC=83=81=ED=83=9C=20=EA=B7=B8?= =?UTF-8?q?=EB=8C=80=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 From 9782c831fbb39fab9856f160f172968aaf359088 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 12 Nov 2026 07:35:44 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat(deploy):=20=EC=9A=B4=EC=98=81=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=EB=A5=BC=20Gitea=20=EB=A0=88?= =?UTF-8?q?=EC=A7=80=EC=8A=A4=ED=8A=B8=EB=A6=AC=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=B0=9B=EA=B3=A0=20=EA=B6=8C=ED=95=9C=EC=9D=84=20=EC=A4=84?= =?UTF-8?q?=EC=9D=B8=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 운영 backend·frontend는 imagePullPolicy: Never로 노드에 직접 넣은 이미지를 쓴다. 2026-11-09 디스크 사고 때 kubelet 이미지 GC가 그 이미지를 지웠고, 다시 받을 곳이 없어 hyeonworks.com이 내려갔다. redis는 움직이는 태그 redis:7-alpine이다. 세 파드 모두 우선순위가 0이고 securityContext가 비어 있다(k3s 성숙도 점검 2026-11-11, 7.2·7.5절). - backend·frontend 이미지를 git.learn.hyeonworks.com/donghyeon.kang/ tech-log-{backend:46b1cc7,frontend:7a4e201}로, pull을 IfNotPresent로 바꾼다. 태그는 지금 운영과 같다. - redis를 지금 운영이 쓰는 이미지의 digest로 고정한다. - 세 파드에 priorityClassName platform-critical과 seccomp RuntimeDefault를 둔다. - backend는 uid 1000, redis는 uid 999로 runAsNonRoot이고 권한을 모두 버리며 allowPrivilegeEscalation: false다. - frontend는 allowPrivilegeEscalation: false만 둔다. nginx 공식 이미지는 root로 80번을 열고 worker를 내리므로, non-root와 drop ALL은 이미지를 비특권 nginx로 바꾼 뒤에 한다(README에 남은 일로 적음). 버린 대안: frontend에도 drop ALL을 두는 것. nginx가 80번을 열고 사용자를 바꾸는 데 필요한 권한까지 빠져 뜨지 못한다. 위험·한계: 두 이미지가 레지스트리에 올라가기 전에 적용하면 파드가 ErrImagePull로 멈춘다. README가 적용 전 확인을 요구한다. backend는 Recreate라 1분 안팎 멈추고, redis 재시작으로 로그인 세션이 풀린다. 아직 적용하지 않았다. 검증: kubectl diff는 위 칸들만 바뀐다고 보여 준다. kubectl apply --dry-run=server는 통과하고, frontend에 PSA restricted 경고(non-root, drop ALL)만 낸다. desktop Docker에서 같은 조건으로 띄워 봤다. redis는 uid 999·cap-drop ALL·no-new-privileges로 PONG을 돌려준다. backend는 uid 1000으로 Tomcat과 DB 연결 시도까지 권한 오류 없이 뜬다. frontend는 no-new-privileges와 기본 seccomp에서 /config.json 200이다. 이 repo의 pnpm 게이트는 돌리지 않았다(YAML과 README만 바뀜). --- deploy/production/README.md | 55 ++++++++++++++++++++++ deploy/production/backend-deployment.yaml | 17 +++++-- deploy/production/frontend-deployment.yaml | 11 +++-- deploy/production/redis-deployment.yaml | 15 +++++- 4 files changed, 90 insertions(+), 8 deletions(-) create mode 100644 deploy/production/README.md diff --git a/deploy/production/README.md b/deploy/production/README.md new file mode 100644 index 0000000..bba926a --- /dev/null +++ b/deploy/production/README.md @@ -0,0 +1,55 @@ +# hyeonworks.com 운영 매니페스트 + +`hyeonworks-prod` namespace의 앱 쪽 객체 정본이다(소유자 결정 2026-11-11: 앱 쪽은 tech-log repo +`deploy/`). 플랫폼 쪽(Namespace, techlog DB Role·Database, 다른 namespace의 NetworkPolicy·Probe· +경보·대시보드)은 platform-core `services/tenants/techlog`가 맡는다. `hyeonworks-secrets` Secret은 +Git 밖에서 만든다. + +| 파일 | 객체 | +| --- | --- | +| `backend-*.yaml` | `techlog-backend` Deployment, Service `techlog-backend`·`techlog-management`, ServiceMonitor, ConfigMap `techlog-logging` | +| `redis-*.yaml` | 세션 저장소 `redis` Deployment·Service(저장 안 함, 재시작하면 로그인이 풀린다) | +| `frontend-*.yaml` | `techlog-frontend` Deployment·Service | +| `ingress.yaml` | `hyeonworks.com` 경로: `/api`·`/oauth2`·`/login`·`/logout` → backend, 나머지 → frontend | +| `network-policies.yaml` | namespace 안 기본 거부와 허용 여섯 | + +## 이미지와 실행 사용자 + +| 컨테이너 | 이미지 | pull | 사용자 | +| --- | --- | --- | --- | +| backend | `git.learn.hyeonworks.com/donghyeon.kang/tech-log-backend:46b1cc7` | `IfNotPresent` | uid 1000(이미지의 `app`), 권한 전부 버림 | +| frontend | `git.learn.hyeonworks.com/donghyeon.kang/tech-log-frontend:7a4e201` | `IfNotPresent` | root(nginx). `allowPrivilegeEscalation: false`만 | +| redis | `redis@sha256:c5d34a98…`(지금 운영이 쓰는 `redis:7-alpine`의 digest) | `IfNotPresent` | uid 999(이미지의 `redis`), 권한 전부 버림 | + +- 예전에는 `imagePullPolicy: Never`로 노드에 직접 넣은 이미지를 썼다. 2026-11-09 디스크 사고 때 + kubelet 이미지 GC가 그 이미지를 지웠고, 다시 받을 곳이 없어 운영이 내려갔다. 이제 Gitea 컨테이너 + 레지스트리에서 다시 받는다. +- 세 파드 모두 `priorityClassName: platform-critical`(platform-core `services/priority-classes`)이고 + seccomp는 `RuntimeDefault`다. +- **frontend non-root는 남은 일이다.** nginx 공식 이미지는 root로 시작해 80번을 열고 worker를 + `nginx`로 내린다. 권한을 버리거나 non-root로 돌리려면 이미지를 비특권 nginx(8080)로 바꾸고 Service + `targetPort`와 probe를 같이 바꿔야 한다. + +## 적용 + +전제(하나라도 없으면 적용하지 않는다): + +1. 두 이미지가 Gitea 레지스트리에 있다. 익명 pull이 되는지 노드에서 확인한다. + `sudo k3s crictl pull git.learn.hyeonworks.com/donghyeon.kang/tech-log-backend:46b1cc7` + (frontend도 같다). 미리 받아 두면 backend(Recreate)가 멈추는 시간이 짧아진다. +2. PriorityClass `platform-critical`이 있다: `kubectl get priorityclass platform-critical`. +3. Secret `hyeonworks-prod/hyeonworks-secrets`가 있다. + +```bash +curl -s -o /dev/null -w '%{http_code}\n' https://hyeonworks.com/ +kubectl diff -k deploy/production +kubectl apply -k deploy/production +kubectl -n hyeonworks-prod rollout status deploy/techlog-backend deploy/techlog-frontend deploy/redis +curl -s -o /dev/null -w '%{http_code}\n' https://hyeonworks.com/ +curl -s -o /dev/null -w '%{http_code}\n' https://hyeonworks.com/api/v1/public/home +``` + +- backend는 `Recreate`라 새 파드가 준비될 때까지 API가 멈춘다(1분 안팎). +- redis가 다시 시작되면 로그인 세션이 모두 풀린다. + +되돌리기: `kubectl -n hyeonworks-prod rollout undo deploy/<이름>`. 그 뒤 이 폴더를 되돌리는 커밋을 만든다. diff --git a/deploy/production/backend-deployment.yaml b/deploy/production/backend-deployment.yaml index dde0160..7b06333 100644 --- a/deploy/production/backend-deployment.yaml +++ b/deploy/production/backend-deployment.yaml @@ -122,8 +122,8 @@ spec: value: redis.hyeonworks-prod.svc.cluster.local:6379 - name: APP_TRACING_ENABLED value: 'true' - image: tech-log-backend:46b1cc7 - imagePullPolicy: Never + image: git.learn.hyeonworks.com/donghyeon.kang/tech-log-backend:46b1cc7 + imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 3 httpGet: @@ -167,12 +167,23 @@ spec: - mountPath: /etc/techlog-logging name: logging-config readOnly: true + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler - securityContext: {} + securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + seccompProfile: + type: RuntimeDefault terminationGracePeriodSeconds: 30 volumes: - configMap: name: techlog-logging name: logging-config + priorityClassName: platform-critical diff --git a/deploy/production/frontend-deployment.yaml b/deploy/production/frontend-deployment.yaml index 0848864..06aec0b 100644 --- a/deploy/production/frontend-deployment.yaml +++ b/deploy/production/frontend-deployment.yaml @@ -21,8 +21,8 @@ spec: spec: automountServiceAccountToken: false containers: - - image: docker.io/library/tech-log-frontend:7a4e201 - imagePullPolicy: Never + - image: git.learn.hyeonworks.com/donghyeon.kang/tech-log-frontend:7a4e201 + imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 3 httpGet: @@ -56,8 +56,13 @@ spec: memory: 32Mi terminationMessagePath: /dev/termination-log terminationMessagePolicy: File + securityContext: + allowPrivilegeEscalation: false dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler - securityContext: {} + securityContext: + seccompProfile: + type: RuntimeDefault terminationGracePeriodSeconds: 30 + priorityClassName: platform-critical diff --git a/deploy/production/redis-deployment.yaml b/deploy/production/redis-deployment.yaml index 784c0c0..1fa9e28 100644 --- a/deploy/production/redis-deployment.yaml +++ b/deploy/production/redis-deployment.yaml @@ -24,7 +24,7 @@ spec: - '' - --appendonly - 'no' - image: redis:7-alpine + image: docker.io/library/redis@sha256:c5d34a98396a4775e223c74e929162c35c5a2182901ba26b50ade939941ce14b imagePullPolicy: IfNotPresent livenessProbe: exec: @@ -59,8 +59,19 @@ spec: memory: 64Mi terminationMessagePath: /dev/termination-log terminationMessagePolicy: File + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler - securityContext: {} + securityContext: + runAsNonRoot: true + runAsUser: 999 + runAsGroup: 999 + seccompProfile: + type: RuntimeDefault terminationGracePeriodSeconds: 30 + priorityClassName: platform-critical