7.7.2.2. ProfileBindings를 사용하여 프로필에 워크로드 바인딩
ProfileBinding 리소스를 사용하여 보안 프로필을 컨테이너의 SecurityContext 에 바인딩할 수 있습니다.
프로세스
quay.io/security-profiles-operator/test-nginx-unprivileged:1.21이미지를 사용하는 Pod를SelinuxProfile프로필 예제에 바인딩하려면 Pod 및SelinuxProfile오브젝트를 사용하여 동일한 네임스페이스에ProfileBinding오브젝트를 생성합니다.apiVersion: security-profiles-operator.x-k8s.io/v1alpha1 kind: ProfileBinding metadata: namespace: my-namespace name: nginx-binding spec: profileRef: kind: SelinuxProfile1 name: profile2 image: quay.io/security-profiles-operator/test-nginx-unprivileged:1.213 다음 명령을 실행하여
enable-binding=true로 네임스페이스에 레이블을 지정합니다.$ oc label ns my-namespace spo.x-k8s.io/enable-binding=truetest-pod.yaml이라는 Pod를 정의합니다.apiVersion: v1 kind: Pod metadata: name: test-pod spec: containers: - name: test-container image: quay.io/security-profiles-operator/test-nginx-unprivileged:1.21Pod를 생성합니다.
$ oc create -f test-pod.yaml참고Pod가 이미 존재하는 경우 바인딩이 제대로 작동하려면 Pod를 다시 생성해야 합니다.
검증
다음 명령을 실행하여 Pod가
ProfileBinding을 상속하는지 확인합니다.$ oc get pod test-pod -o jsonpath='{.spec.containers[*].securityContext.seLinuxOptions.type}'출력 예
profile.process