7.7.2.3. 컨트롤러 및 SecurityContextConstraints 복제
배포 또는 데몬 세트와 같은 컨트롤러를 복제하기 위한 SELinux 정책을 배포할 때 컨트롤러에서 생성한 Pod 오브젝트는 워크로드를 생성하는 사용자의 ID로 실행되지 않습니다. ServiceAccount 를 선택하지 않으면 사용자 정의 보안 정책 사용을 허용하지 않는 restricted SCC( SecurityContextConstraints )를 사용하여 Pod가 되돌릴 수 있습니다.
프로세스
다음 명령을 실행하여 프로젝트를 생성합니다.
$ oc new-project nginx-secure다음
RoleBinding오브젝트를 생성하여nginx-secure네임스페이스에서 SELinux 정책을 사용할 수 있습니다.kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: spo-nginx namespace: nginx-secure subjects: - kind: ServiceAccount name: spo-deploy-test roleRef: kind: Role name: spo-nginx apiGroup: rbac.authorization.k8s.ioRole오브젝트를 생성합니다.apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: creationTimestamp: null name: spo-nginx namespace: nginx-secure rules: - apiGroups: - security.openshift.io resources: - securitycontextconstraints resourceNames: - privileged verbs: - useServiceAccount오브젝트를 생성합니다.apiVersion: v1 kind: ServiceAccount metadata: creationTimestamp: null name: spo-deploy-test namespace: nginx-secureDeployment오브젝트를 생성합니다.apiVersion: apps/v1 kind: Deployment metadata: name: selinux-test namespace: nginx-secure metadata: labels: app: selinux-test spec: replicas: 3 selector: matchLabels: app: selinux-test template: metadata: labels: app: selinux-test spec: serviceAccountName: spo-deploy-test securityContext: seLinuxOptions: type: nginx-secure.process1 containers: - name: nginx-unpriv image: quay.io/security-profiles-operator/test-nginx-unprivileged:1.21 ports: - containerPort: 8080- 1
- 배포가 생성되기 전에
.seLinuxOptions.type이 있어야 합니다.참고SELinux 유형은 워크로드에 지정되지 않으며 SCC에서 처리합니다. 배포 및
ReplicaSet을 통해 Pod를 생성하면 Pod가 적절한 프로필과 함께 실행됩니다.
올바른 서비스 계정에서만 SCC를 사용할 수 있는지 확인합니다. 자세한 내용은 추가 리소스를 참조하십시오.