1. pod scope로 컨테이너 실행 유저 설정
#pod spec영역에 설정
apiVersion: v1
kind: Pod
metadata:
name: security-context-demo
spec:
securityContext: #containers와 같은 레벨에 작성
runAsUser: 1000
containers:
- name: sec-ctx-demo
image: busybox:1.28
command: [ "sh", "-c", "sleep 1h" ]
2. container scope로 실행 유저 설정
#정의파일
apiVersion: v1
kind: Pod
metadata:
name: security-context-demo-2
spec:
securityContext:
runAsUser: 1000
containers:
- name: sec-ctx-demo-2
image: gcr.io/google-samples/hello-app:2.0
securityContext: #컨테이너 정의 영역에 명시
runAsUser: 2000
allowPrivilegeEscalation: false
Configure a Security Context for a Pod or Container
A security context defines privilege and access control settings for a Pod or Container. Security context settings include, but are not limited to: Discretionary Access Control: Permission to access an object, like a file, is based on user ID (UID) and gro
kubernetes.io
'ops > kubernetes' 카테고리의 다른 글
| 계속 Terminated 상태인 namespace 삭제하기 (0) | 2026.02.03 |
|---|---|
| is invalid: metadata.annotations: Too long: may not be more than 262144 bytes (0) | 2026.02.03 |
| docker registry용 secret 생성하기 (0) | 2026.01.30 |
| pv & pvc storage class (0) | 2026.01.24 |
| 쿠버네티스 클러스터에서 프로메테우스 metric을 그라파나 data source 로 사용하기 - 3 (0) | 2026.01.13 |