Files
DongHyeonka 9782c831fb feat(deploy): 운영 이미지를 Gitea 레지스트리에서 받고 권한을 줄인다
운영 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만 바뀜).
2026-11-12 07:35:44 +09:00

78 lines
1.9 KiB
YAML

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: docker.io/library/redis@sha256:c5d34a98396a4775e223c74e929162c35c5a2182901ba26b50ade939941ce14b
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
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext:
runAsNonRoot: true
runAsUser: 999
runAsGroup: 999
seccompProfile:
type: RuntimeDefault
terminationGracePeriodSeconds: 30
priorityClassName: platform-critical