Files
tech-log-frontend/deploy/production/frontend-nonroot/frontend-deployment-patch.yaml
DongHyeonka 8c93cb05bc feat(deploy): frontend를 non-root로 돌리는 component를 둔다
비특권 nginx 이미지는 uid 101로 8080을 연다. 지금 운영 매니페스트는 pod
포트 80, probe 80, root를 전제로 한다.

deploy/production/frontend-nonroot에 Kustomize component를 둔다. 켜면
frontend Deployment가 containerPort·probe 8080, runAsNonRoot·uid/gid 101,
capabilities drop ALL이 되고, Service targetPort가 8080, Traefik →
frontend NetworkPolicy 포트가 8080이 된다. Service port는 80 그대로라
Ingress는 바뀌지 않는다. ports 목록은 containerPort로 합쳐져 80이
남으므로 $patch: replace로 바꾼다.

기본 경로에는 넣지 않는다. 지금 운영 이미지 7a4e201은 root로 80을 열어,
켜면 probe가 모두 실패한다. README는 이미지를 비특권 Dockerfile이 들어간
commit에서 다시 만들고, 운영에만 있는 로컬 4커밋도 그 commit에 들어가
있어야 한다고 적는다. 그 이미지로 태그를 바꾸는 같은 커밋에서 켠다.

위험·한계: 운영 frontend의 source(7a4e201)가 Gitea에 없어서, 지금 main에서
이미지를 만들면 운영에만 있는 4커밋이 빠진다. 아직 적용하지 않았다.

검증: component를 켠 렌더에서 pod 포트·probe가 8080, Service targetPort
8080, NetworkPolicy 8080, securityContext가 위와 같다. kubectl apply
--dry-run=server는 통과하고, frontend의 PSA restricted 경고가 사라졌다.
2026-11-12 08:22:14 +09:00

36 lines
919 B
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: techlog-frontend
spec:
template:
spec:
securityContext:
runAsNonRoot: true
runAsUser: 101
runAsGroup: 101
seccompProfile:
type: RuntimeDefault
containers:
- name: frontend
# replace, not merge: ports merge on containerPort, which would
# keep the old 80 entry next to 8080 under the same name.
ports:
- $patch: replace
- name: http
containerPort: 8080
protocol: TCP
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
livenessProbe:
httpGet:
path: /config.json
port: 8080
readinessProbe:
httpGet:
path: /config.json
port: 8080