5.14. oc-compliance 플러그인 사용


Compliance Operator 는 클러스터에 대한 많은 검사 및 수정을 자동화하지만 클러스터를 규정 준수로 전환하려면 관리자가 Compliance Operator API 및 기타 구성 요소와 상호 작용해야 하는 경우가 많습니다. oc-compliance 플러그인을 사용하면 프로세스를 더 쉽게 수행할 수 있습니다.

5.14.1. oc-compliance 플러그인 설치

절차

  1. oc-compliance 이미지를 추출하여 oc-compliance 바이너리를 가져옵니다.

    $ podman run --rm -v ~/.local/bin:/mnt/out:Z registry.redhat.io/compliance/oc-compliance-rhel8:stable /bin/cp /usr/bin/oc-compliance /mnt/out/
    Copy to Clipboard Toggle word wrap

    출력 예

    W0611 20:35:46.486903   11354 manifest.go:440] Chose linux/amd64 manifest from the manifest list.
    Copy to Clipboard Toggle word wrap

    이제 oc-compliance를 실행할 수 있습니다.

5.14.2. 원시 결과 가져오기

규정 준수 검사가 완료되면 결과 ComplianceCheckResult CR(사용자 정의 리소스)에 개별 검사 결과가 나열됩니다. 그러나 관리자 또는 감사자는 검사에 대한 전체 세부 정보가 필요할 수 있습니다. OpenSCAP 툴은 자세한 결과를 사용하여 AMQP(Advanced Recording Format) 포맷 파일을 생성합니다. 이 ARF 파일은 구성 맵 또는 기타 표준 Kubernetes 리소스에 저장하기에 너무 크므로 이를 포함할 영구 볼륨(PV)이 생성됩니다.

절차

  • Compliance Operator를 사용하여 PV에서 결과를 가져오는 작업은 4단계 프로세스입니다. 그러나 oc-compliance 플러그인을 사용하면 단일 명령을 사용할 수 있습니다.

    $ oc compliance fetch-raw <object-type> <object-name> -o <output-path>
    Copy to Clipboard Toggle word wrap
  • <object-type>은 검사가 시작된 오브젝트에 따라 scansettingbinding, compliancescan 또는 compliancesuite 일 수 있습니다.
  • <object-name>은 ARF 파일을 수집할 바인딩, 제품군 또는 검사 오브젝트의 이름이고 <output-path>는 결과를 배치할 로컬 디렉터리입니다.

    예를 들면 다음과 같습니다.

    $ oc compliance fetch-raw scansettingbindings my-binding -o /tmp/
    Copy to Clipboard Toggle word wrap

    출력 예

    Fetching results for my-binding scans: ocp4-cis, ocp4-cis-node-worker, ocp4-cis-node-master
    Fetching raw compliance results for scan 'ocp4-cis'.......
    The raw compliance results are available in the following directory: /tmp/ocp4-cis
    Fetching raw compliance results for scan 'ocp4-cis-node-worker'...........
    The raw compliance results are available in the following directory: /tmp/ocp4-cis-node-worker
    Fetching raw compliance results for scan 'ocp4-cis-node-master'......
    The raw compliance results are available in the following directory: /tmp/ocp4-cis-node-master
    Copy to Clipboard Toggle word wrap

디렉터리에서 파일 목록을 확인합니다.

$ ls /tmp/ocp4-cis-node-master/
Copy to Clipboard Toggle word wrap

출력 예

ocp4-cis-node-master-ip-10-0-128-89.ec2.internal-pod.xml.bzip2  ocp4-cis-node-master-ip-10-0-150-5.ec2.internal-pod.xml.bzip2  ocp4-cis-node-master-ip-10-0-163-32.ec2.internal-pod.xml.bzip2
Copy to Clipboard Toggle word wrap

결과를 추출합니다.

$ bunzip2 -c resultsdir/worker-scan/worker-scan-stage-459-tqkg7-compute-0-pod.xml.bzip2 > resultsdir/worker-scan/worker-scan-ip-10-0-170-231.us-east-2.compute.internal-pod.xml
Copy to Clipboard Toggle word wrap

결과를 확인합니다.

$ ls resultsdir/worker-scan/
Copy to Clipboard Toggle word wrap

출력 예

worker-scan-ip-10-0-170-231.us-east-2.compute.internal-pod.xml
worker-scan-stage-459-tqkg7-compute-0-pod.xml.bzip2
worker-scan-stage-459-tqkg7-compute-1-pod.xml.bzip2
Copy to Clipboard Toggle word wrap

5.14.3. 검사 재실행

예약된 작업으로 스캔을 실행할 수 있지만 수정을 적용한 후 또는 클러스터에 대한 기타 변경이 이루어진 경우 필요에 따라 검사를 다시 실행해야 합니다.

절차

  • Compliance Operator를 사용하여 검사를 다시 실행하려면 검사 오브젝트에서 주석을 사용해야 합니다. 그러나 oc-compliance 플러그인을 사용하면 단일 명령으로 검사를 재실행할 수 있습니다. 다음 명령을 입력하여 my-binding 이라는 ScanSettingBinding 오브젝트에 대한 검사를 재실행합니다.

    $ oc compliance rerun-now scansettingbindings my-binding
    Copy to Clipboard Toggle word wrap

    출력 예

    Rerunning scans from 'my-binding': ocp4-cis
    Re-running scan 'openshift-compliance/ocp4-cis'
    Copy to Clipboard Toggle word wrap

5.14.4. ScanSettingBinding 사용자 정의 리소스 사용

Compliance Operator에서 제공하는 ScanSettingScanSettingBinding CR(사용자 정의 리소스)을 사용하는 경우 schedule, machine roles, tolerations 등과 같은 공통 검사 옵션 세트를 사용하는 동안 여러 프로필 검사를 실행할 수 있습니다. 여러 ComplianceSuite 또는 ComplianceScan 오브젝트로 작업하는 것보다 쉽지만 새로운 사용자를 혼란스럽게 할 수 있습니다.

oc compliance bind 하위 명령은 ScanSettingBinding CR을 생성하는 데 도움이 됩니다.

절차

  1. 다음을 실행합니다.

    $ oc compliance bind [--dry-run] -N <binding name> [-S <scansetting name>] <objtype/objname> [..<objtype/objname>]
    Copy to Clipboard Toggle word wrap
    • -S 플래그를 생략하면 Compliance Operator에서 제공하는 default 검사 설정이 사용됩니다.
    • 오브젝트 유형은 Kubernetes 오브젝트 유형으로 profile 또는 tailoredprofile 일 수 있습니다. 두 개 이상의 오브젝트를 제공할 수 있습니다.
    • 오브젝트 이름은 Kubernetes 리소스의 이름입니다 (예: .metadata.name).
    • --dry-run 옵션을 추가하여 생성된 오브젝트의 YAML 파일을 표시합니다.

      예를 들어 다음 프로필 및 검사 설정이 제공됩니다.

      $ oc get profile.compliance -n openshift-compliance
      Copy to Clipboard Toggle word wrap

      출력 예

      NAME              AGE
      ocp4-cis          9m54s
      ocp4-cis-node     9m54s
      ocp4-e8           9m54s
      ocp4-moderate     9m54s
      ocp4-ncp          9m54s
      rhcos4-e8         9m54s
      rhcos4-moderate   9m54s
      rhcos4-ncp        9m54s
      rhcos4-ospp       9m54s
      rhcos4-stig       9m54s
      Copy to Clipboard Toggle word wrap

      $ oc get scansettings -n openshift-compliance
      Copy to Clipboard Toggle word wrap

      출력 예

      NAME                 AGE
      default              10m
      default-auto-apply   10m
      Copy to Clipboard Toggle word wrap

  2. default 설정을 ocp4-cisocp4-cis-node 프로필에 적용하려면 다음을 실행합니다.

    $ oc compliance bind -N my-binding profile/ocp4-cis profile/ocp4-cis-node
    Copy to Clipboard Toggle word wrap

    출력 예

    Creating ScanSettingBinding my-binding
    Copy to Clipboard Toggle word wrap

    ScanSettingBinding CR이 생성되면 바인딩된 프로파일은 관련 설정으로 두 프로필의 검사를 시작합니다. 전반적으로 이것은 Compliance Operator로 스캔을 시작하는 가장 빠른 방법입니다.

5.14.5. 인쇄 제어

컴플라이언스 표준은 일반적으로 다음과 같이 계층 구조로 구성됩니다.

  • 벤치마크는 특정 표준에 대한 제어 집합의 최상위 정의입니다. 예를 들어 FedRAMP Moderate 또는 Center for Internet Security (CIS) v.1.6.0입니다.
  • 제어는 벤치마크를 준수하기 위해 충족되어야 하는 일련의 요구 사항을 설명합니다. 예: FedRAMP AC-01(액세스 제어 정책 및 절차)
  • 규칙은 규정을 준수하는 시스템에 특정한 단일 검사이며 이러한 규칙 중 하나 이상이 제어에 매핑됩니다.
  • Compliance Operator는 단일 벤치마크의 프로필로 규칙 그룹화를 처리합니다. 프로필의 규칙 집합이 충족되도록 제어하는 것을 결정하기 어려울 수 있습니다.

절차

  • oc compliance control 하위 명령은 표준에 대한 보고서를 제공하고 지정된 프로필이 충족되도록 제어합니다.

    $ oc compliance controls profile ocp4-cis-node
    Copy to Clipboard Toggle word wrap

    출력 예

    +-----------+----------+
    | FRAMEWORK | CONTROLS |
    +-----------+----------+
    | CIS-OCP   | 1.1.1    |
    +           +----------+
    |           | 1.1.10   |
    +           +----------+
    |           | 1.1.11   |
    +           +----------+
    ...
    Copy to Clipboard Toggle word wrap

5.14.6. 컴플라이언스 수정 세부 정보 가져오기

Compliance Operator는 클러스터를 준수하는 데 필요한 변경 사항을 자동화하는 데 사용되는 수정 오브젝트를 제공합니다. fetch-fixes 하위 명령은 어떤 구성 수정이 사용되는지 정확하게 이해하는 데 도움이 될 수 있습니다. fetch-fixes 하위 명령을 사용하여 프로필, 규칙 또는 ComplianceRemediation 오브젝트에서 검사할 디렉터리로 수정 오브젝트를 추출합니다.

절차

  1. 프로필의 수정을 확인합니다.

    $ oc compliance fetch-fixes profile ocp4-cis -o /tmp
    Copy to Clipboard Toggle word wrap

    출력 예

    No fixes to persist for rule 'ocp4-api-server-api-priority-flowschema-catch-all' 
    1
    
    No fixes to persist for rule 'ocp4-api-server-api-priority-gate-enabled'
    No fixes to persist for rule 'ocp4-api-server-audit-log-maxbackup'
    Persisted rule fix to /tmp/ocp4-api-server-audit-log-maxsize.yaml
    No fixes to persist for rule 'ocp4-api-server-audit-log-path'
    No fixes to persist for rule 'ocp4-api-server-auth-mode-no-aa'
    No fixes to persist for rule 'ocp4-api-server-auth-mode-node'
    No fixes to persist for rule 'ocp4-api-server-auth-mode-rbac'
    No fixes to persist for rule 'ocp4-api-server-basic-auth'
    No fixes to persist for rule 'ocp4-api-server-bind-address'
    No fixes to persist for rule 'ocp4-api-server-client-ca'
    Persisted rule fix to /tmp/ocp4-api-server-encryption-provider-cipher.yaml
    Persisted rule fix to /tmp/ocp4-api-server-encryption-provider-config.yaml
    Copy to Clipboard Toggle word wrap

    1
    규칙을 자동으로 수정할 수 없거나 수정이 제공되지 않았기 때문에 프로필에 해당 수정 조치가 없는 규칙이 있을 때마다 No fixes to persist 경고가 예상됩니다.
  2. YAML 파일의 샘플을 볼 수 있습니다. head 명령은 처음 10행을 표시합니다.

    $ head /tmp/ocp4-api-server-audit-log-maxsize.yaml
    Copy to Clipboard Toggle word wrap

    출력 예

    apiVersion: config.openshift.io/v1
    kind: APIServer
    metadata:
      name: cluster
    spec:
      maximumFileSizeMegabytes: 100
    Copy to Clipboard Toggle word wrap

  3. 검사 후 생성된 ComplianceRemediation 오브젝트에서 수정을 확인합니다.

    $ oc get complianceremediations -n openshift-compliance
    Copy to Clipboard Toggle word wrap

    출력 예

    NAME                                             STATE
    ocp4-cis-api-server-encryption-provider-cipher   NotApplied
    ocp4-cis-api-server-encryption-provider-config   NotApplied
    Copy to Clipboard Toggle word wrap

    $ oc compliance fetch-fixes complianceremediations ocp4-cis-api-server-encryption-provider-cipher -o /tmp
    Copy to Clipboard Toggle word wrap

    출력 예

    Persisted compliance remediation fix to /tmp/ocp4-cis-api-server-encryption-provider-cipher.yaml
    Copy to Clipboard Toggle word wrap

  4. YAML 파일의 샘플을 볼 수 있습니다. head 명령은 처음 10행을 표시합니다.

    $ head /tmp/ocp4-cis-api-server-encryption-provider-cipher.yaml
    Copy to Clipboard Toggle word wrap

    출력 예

    apiVersion: config.openshift.io/v1
    kind: APIServer
    metadata:
      name: cluster
    spec:
      encryption:
        type: aescbc
    Copy to Clipboard Toggle word wrap

주의

수정을 직접 적용하기 전에 주의하십시오. 중간 프로파일의 usbguard 규칙과 같은 일부 수정 사항은 일괄적으로 적용되지 않을 수 있습니다. 이 경우 종속성을 해결하고 클러스터가 정상 상태로 유지되도록 Compliance Operator가 규칙을 적용하도록 허용합니다.

5.14.7. ComplianceCheckResult 오브젝트 세부 정보 보기

검사 실행이 완료되면 개별 검사 규칙에 대해 ComplianceCheckResult 오브젝트가 생성됩니다. view-result 하위 명령은 사용자가 읽을 수 있는 ComplianceCheckResult 오브젝트 세부 정보 출력을 제공합니다.

절차

  • 다음을 실행합니다.

    $ oc compliance view-result ocp4-cis-scheduler-no-bind-address
    Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat