비특권 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 경고가 사라졌다.
16 lines
614 B
YAML
16 lines
614 B
YAML
apiVersion: kustomize.config.k8s.io/v1alpha1
|
|
kind: Component
|
|
|
|
# Opt-in: runs techlog-frontend as uid 101 on port 8080 with every capability
|
|
# dropped. Needs an image built from a commit that has the unprivileged
|
|
# Dockerfile; the 7a4e201 image listens on 80 as root and would fail every
|
|
# probe. Enable it in the same commit that moves the frontend image tag, by
|
|
# adding
|
|
# components:
|
|
# - frontend-nonroot
|
|
# to ../kustomization.yaml. See ../README.md ("frontend non-root").
|
|
patches:
|
|
- path: frontend-deployment-patch.yaml
|
|
- path: frontend-service-patch.yaml
|
|
- path: frontend-network-policy-patch.yaml
|