이 페이지 개선에 도움 주기
이 사용자 가이드에 기여하려면 모든 페이지의 오른쪽 창에 있는 GitHub에서 이 페이지 편집 링크를 선택합니다.
Amazon EKS에서 생성한 포드 보안 정책(PSP) 이해
Kubernetes 포드 보안 정책 승인 컨트롤러는 일련의 규칙을 기준으로 포드 생성 및 업데이트 요청을 검증합니다. 기본적으로 Amazon EKS 클러스터는 제한 없이 완전히 허용되는 보안 정책과 함께 제공됩니다. 자세한 내용은 Kubernetes 설명서의 Pod Security Policies(포드 보안 정책)
참고
PodSecurityPolicy
(PSP)는 Kubernetes 버전 1.21
에서 더 이상 사용되지 않으며 Kubernetes 1.25
에서 제거되었습니다. PSP는 포드 보안 표준(PSS)1.25
의 PSP 제거를 해결하려면 Amazon EKS에서 PSS를 구현하는 것이 좋습니다. 자세한 내용은 AWS 블로그의 Amazon EKS에서 포드 보안 표준 구현
Amazon EKS 기본 포드 보안 정책
Kubernetes 버전 1.13
이상의 Amazon EKS 클러스터에는 eks.privileged
라는 기본 포드 보안 정책이 있습니다. 이 정책에는 시스템에 수용할 수 있는 포드 종류에 대한 제한이 없기 때문에 PodSecurityPolicy
컨트롤러가 비활성화된 상태로 Kubernestes를 실행하는 것과 같습니다.
참고
이 정책은 PodSecurityPolicy
컨트롤러가 활성화되지 않은 클러스터와의 이전 버전 호환성을 유지하기 위해 만들어졌습니다. 클러스터와 개별 네임스페이스 및 서비스 계정에 대해 더 제한적인 정책을 만든 다음 기본 정책을 삭제해 더 제한적인 정책을 활성화할 수 있습니다.
다음 명령을 사용하여 기본 정책을 볼 수 있습니다.
kubectl get psp eks.privileged
예제 출력은 다음과 같습니다.
NAME PRIV CAPS SELINUX RUNASUSER FSGROUP SUPGROUP READONLYROOTFS VOLUMES eks.privileged true * RunAsAny RunAsAny RunAsAny RunAsAny false *
세부 정보를 추가하려면 다음 명령을 사용하여 정책을 설명할 수 있습니다.
kubectl describe psp eks.privileged
예제 출력은 다음과 같습니다.
Name: eks.privileged Settings: Allow Privileged: true Allow Privilege Escalation: 0xc0004ce5f8 Default Add Capabilities: <none> Required Drop Capabilities: <none> Allowed Capabilities: * Allowed Volume Types: * Allow Host Network: true Allow Host Ports: 0-65535 Allow Host PID: true Allow Host IPC: true Read Only Root Filesystem: false SELinux Context Strategy: RunAsAny User: <none> Role: <none> Type: <none> Level: <none> Run As User Strategy: RunAsAny Ranges: <none> FSGroup Strategy: RunAsAny Ranges: <none> Supplemental Groups Strategy: RunAsAny Ranges: <none>
기본 포드 보안 정책 설치 또는 복원에서 eks.privileged
포드 보안 정책, 해당 클러스터 역할, 클러스터 역할 바인딩에 대한 완전한 YAML 파일을 볼 수 있습니다.
기본 Amazon EKS 포드 보안 정책 삭제
포드에 대해 더 제한적인 정책을 생성하는 경우 그런 다음 기본 Amazon EKS eks.privileged
포드 보안 정책을 삭제하여 사용자 지정 정책을 사용 설정할 수 있습니다.
중요
CNI 플러그인 버전 1.7.0
이상을 사용하고 있고 DaemonSet에 의해 배포된 aws-node
포드에 사용되는 aws-node
Kubernetes 서비스 계정에 사용자 지정 포드 보안 정책을 할당한 경우 정책의 allowedCapabilities
섹션에 NET_ADMIN
이 있고 정책의 spec
에 hostNetwork: true
와 privileged: true
가 있어야 합니다.
-
기본 포드 보안 정책 설치 또는 복원에 있는 예제 파일의 콘텐츠를 사용하여
privileged-podsecuritypolicy.yaml
이라는 파일을 생성하세요. -
다음 명령을 사용하여 YAML을 삭제합니다. 이렇게 하면 기본 포드 보안 정책인
ClusterRole
및 이와 연결된ClusterRoleBinding
이 삭제됩니다.kubectl delete -f privileged-podsecuritypolicy.yaml
기본 포드 보안 정책을 설치 또는 복원
이전 버전의 Kubernetes에서 업그레이드하거나 기본 Amazon EKS eks.privileged
포드 보안 정책을 수정 또는 삭제한 경우 다음 단계에 따라 복원할 수 있습니다.
-
다음 콘텐츠로
privileged-podsecuritypolicy.yaml
이라는 파일을 생성합니다.apiVersion: policy/v1beta1 kind: PodSecurityPolicy metadata: name: eks.privileged annotations: kubernetes.io/description: 'privileged allows full unrestricted access to Pod features, as if the PodSecurityPolicy controller was not enabled.' seccomp.security.alpha.kubernetes.io/allowedProfileNames: '*' labels: kubernetes.io/cluster-service: "true" eks.amazonaws.com/component: pod-security-policy spec: privileged: true allowPrivilegeEscalation: true allowedCapabilities: - '*' volumes: - '*' hostNetwork: true hostPorts: - min: 0 max: 65535 hostIPC: true hostPID: true runAsUser: rule: 'RunAsAny' seLinux: rule: 'RunAsAny' supplementalGroups: rule: 'RunAsAny' fsGroup: rule: 'RunAsAny' readOnlyRootFilesystem: false --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: eks:podsecuritypolicy:privileged labels: kubernetes.io/cluster-service: "true" eks.amazonaws.com/component: pod-security-policy rules: - apiGroups: - policy resourceNames: - eks.privileged resources: - podsecuritypolicies verbs: - use --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: eks:podsecuritypolicy:authenticated annotations: kubernetes.io/description: 'Allow all authenticated users to create privileged Pods.' labels: kubernetes.io/cluster-service: "true" eks.amazonaws.com/component: pod-security-policy roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: eks:podsecuritypolicy:privileged subjects: - kind: Group apiGroup: rbac.authorization.k8s.io name: system:authenticated
-
다음 명령을 사용하여 YAML을 적용합니다.
kubectl apply -f privileged-podsecuritypolicy.yaml