레거시 애플리케이션 PVC를 마운트하는 팟 (Pod) 이 있는 배치 구성에 대해서만 SELinux 레이블 수정
레거시 애플리케이션을 마운트하는 팟 (Pod) 이 있는 배치 구성에서 SELinux 레이블을 수정하여 레거시 애플리케이션 및 openshift-storage 팟 (Pod) 이 파일에서 동일한 SELinux 레이블을 사용하는지 확인하십시오.
프로시저
openshift-storage프로젝트에서 사용하는 MCS (Multi Category Security) 를 사용하여MustRunAs및seLinuxOptions옵션으로 새scc를 작성하십시오.예제 YAML 파일:cat << EOF >> scc.yamlallowHostDirVolumePlugin: false allowHostIPC: false allowHostNetwork: false allowHostPID: false allowHostPorts: false allowPrivilegeEscalation: true allowPrivilegedContainer: false allowedCapabilities: null apiVersion: security.openshift.io/v1 defaultAddCapabilities: null fsGroup: type: MustRunAs groups: - system:authenticated kind: SecurityContextConstraints metadata: annotations: name: restricted-pvselinux priority: null readOnlyRootFilesystem: false requiredDropCapabilities: - KILL - MKNOD - SETUID - SETGID runAsUser: type: MustRunAsRange seLinuxContext: seLinuxOptions: level: s0:c26,c0 type: MustRunAs supplementalGroups: type: RunAsAny users: [] volumes: - configMap - downwardAPI - emptyDir - persistentVolumeClaim - projected - secret EOFoc create -f scc.yaml- 배치를 위한 서비스 계정을 작성하고 새로 작성된
scc에 추가하십시오.- 서비스 계정을 작성하십시오. 여기서 < service_account_name> 은 서비스 계정의 이름입니다.
oc create serviceaccount <service_account_name>예를 들어,
oc create serviceaccount testnamespacesa - 새로 작성된
scc에 서비스 계정을 추가하십시오.oc adm policy add-scc-to-user restricted-pvselinux -z <service_account_name>예를 들어,
oc adm policy add-scc-to-user restricted-pvselinux -z testname
- 서비스 계정을 작성하십시오. 여기서 < service_account_name> 은 서비스 계정의 이름입니다.
- 새로 작성된 서비스 계정을 사용하도록 레거시 애플리케이션 배치를 패치하십시오.이를 통해 배치에서 SELinux 레이블을 지정할 수 있습니다.
oc patch dc/<pod_name> '{"spec":{"template":{"spec":{"serviceAccountName": "<service_account_name>"}}}}'예를 들어,oc patch dc/cephfs-write-workload-generator-no-cache --patch '{"spec":{"template":{"spec":{"serviceAccountName": "testnamespacesa"}}}}' - 배치를 편집하여 배치 구성의 SELinux 레이블에서 사용할 보안 컨텍스트를 지정하십시오.
oc edit dc <pod_name> -n <application_namespace>다음 행을 추가하십시오.spec: template: metadata: securityContext: seLinuxOptions: Level: <security_context_value>- 보안 컨텍스트 값
레거시 애플리케이션 팟 (Pod) 의 CephFS PV및 PVC에서 NSFS 공유 내에 S3 에 대한 전용 폴더를 작성하는 명령을 실행할 때 이 값을 찾을 수 있습니다.
예를 들어,
oc edit dc cephfs-write-workload-generator-no-cache -n testnamespacespec: template: metadata: securityContext: seLinuxOptions: level: s0:c26,c0 - 배치 구성의 SELinux 레이블에서 사용할 보안 컨텍스트가 올바르게 지정되었는지 확인하십시오.
oc get dc <pod_name> -n <application_namespace> -o yaml | grep -A 2 securityContext예를 들어,oc get dc cephfs-write-workload-generator-no-cache -n testnamespace -o yaml | grep -A 2 securityContextsecurityContext: seLinuxOptions: level: s0:c26,c0레거시 애플리케이션이 다시 시작되고
openshift-storage네임스페이스와 동일한 SELinux 레이블을 사용하기 시작합니다.