NIST SP 800-190 정책 제약조건 사용

정책 컨트롤러는 미국 국립 표준 기술 연구소(NIST) 특별 간행물(SP) 800-190 애플리케이션 컨테이너 보안 가이드에 나열된 제어를 구현하는 NIST SP 800-190 번들과 함께 사용할 수 있는 제약조건 템플릿의 기본 라이브러리와 함께 제공됩니다. 이 번들은 이미지 보안, 컨테이너 런타임 보안, 네트워크 보안, 호스트 시스템 보안을 비롯한 애플리케이션 컨테이너 보안을 사용하는 조직을 지원하기 위한 것입니다.

NIST SP 800-190 정책 번들 제약조건

제약조건 이름 제약조건 설명 컨트롤 ID
nist-sp-800-190-restrict-rbac-subjects RBAC 주제에서 이름 사용을 허용된 값으로 제한합니다. AC-2 계정 관리
nist-sp-800-190-restrict-rbac-subjects RBAC 주제에서 이름 사용을 허용된 값으로 제한합니다. AC-3 액세스 시행
nist-sp-800-190-block-secrets-of-type-basic-auth 기본 인증 유형 보안 비밀을 제한합니다. AC-4 정보 흐름 시행
nist-sp-800-190-require-binauthz 허용 웹훅 검증을 위한 Binary Authorization이 필요합니다.
nist-sp-800-190-require-namespace-network-policies 클러스터에 정의된 모든 네임스페이스에 NetworkPolicy가 있어야 합니다.
nist-sp-800-190-restrict-hostpath-volumes HostPath 볼륨의 사용을 제한합니다.
nist-sp-800-190-require-binauthz 허용 웹훅 검증을 위한 Binary Authorization이 필요합니다. AC-6 최소 권한
nist-sp-800-190-restrict-clusteradmin-rolebindings `cluster-admin` 역할 사용을 제한합니다.
nist-sp-800-190-restrict-repos 컨테이너 이미지를 허용된 `repos` 목록으로 제한합니다.
nist-sp-800-190-restrict-role-wildcards `Roles` 및 `ClusterRoles`에서 와일드 카드 사용을 제한합니다.
nist-sp-800-190-nodes-have-consistent-time Container-Optimized OS(COS) 또는 Ubuntu를 OS 이미지로 허용하여 노드에서 일관되고 올바른 시간을 보장합니다. AU-8 타임스탬프
nist-sp-800-190-require-namespace-network-policies 클러스터에 정의된 모든 네임스페이스에 NetworkPolicy가 있어야 합니다. CA-9 내부 시스템 연결
nist-sp-800-190-enforce-config-management 클러스터에 하나 이상의 `RootSync` 객체가 있는 구성 동기화가 실행 중이고 드리프트 방지가 사용 설정되어 있어야 합니다. CM-2 기준 구성
nist-sp-800-190-require-managed-by-label 모든 앱에 유효한 `app.kubernetes.io/managed-by` 라벨이 있어야 합니다.
nist-sp-800-190-apparmor 포드에 허용되는 AppArmor 프로필을 제한합니다. CM-3 구성 변경 제어
nist-sp-800-190-block-secrets-of-type-basic-auth 기본 인증 유형 보안 비밀을 제한합니다.
nist-sp-800-190-capabilities 포드에 허용되는 추가 기능을 제한합니다.
nist-sp-800-190-enforce-config-management 클러스터에 하나 이상의 `RootSync` 객체가 있는 구성 동기화가 실행 중이고 드리프트 방지가 사용 설정되어 있어야 합니다.
nist-sp-800-190-host-namespaces `hostPID` 또는 `hostIPC`를 `true`로 설정하여 컨테이너를 제한합니다.
nist-sp-800-190-host-network `hostNetwork` 플래그를 `true`로 설정하여 컨테이너가 실행되지 않도록 제한합니다.
nist-sp-800-190-privileged-containers `securityContext.privileged`를 `true`로 설정하여 컨테이너를 제한합니다.
nist-sp-800-190-proc-mount-type 포드에 기본 `/proc` 마스크가 필요합니다.
nist-sp-800-190-require-managed-by-label 모든 앱에 유효한 `app.kubernetes.io/managed-by` 라벨이 있어야 합니다.
nist-sp-800-190-restrict-hostpath-volumes HostPath 볼륨의 사용을 제한합니다.
nist-sp-800-190-restrict-volume-types 마운트 가능한 볼륨 유형을 허용된 목록으로 제한합니다.
nist-sp-800-190-seccomp Seccomp 프로필을 `Unconfined`로 명시적으로 설정하지 않아야 합니다.
nist-sp-800-190-selinux 포드의 SELinux 구성을 제한합니다.
nist-sp-800-190-sysctls 포드에 허용되는 Sysctl을 제한합니다.
nist-sp-800-190-enforce-config-management 클러스터에 하나 이상의 `RootSync` 객체가 있는 구성 동기화가 실행 중이고 드리프트 방지가 사용 설정되어 있어야 합니다. CM-4 보안 영향 분석
nist-sp-800-190-require-managed-by-label 모든 앱에 유효한 `app.kubernetes.io/managed-by` 라벨이 있어야 합니다.
nist-sp-800-190-restrict-clusteradmin-rolebindings `cluster-admin` 역할 사용을 제한합니다.
nist-sp-800-190-enforce-config-management 클러스터에 하나 이상의 `RootSync` 객체가 있는 구성 동기화가 실행 중이고 드리프트 방지가 사용 설정되어 있어야 합니다. CM-5 변경 액세스 제한
nist-sp-800-190-require-managed-by-label 모든 앱에 유효한 `app.kubernetes.io/managed-by` 라벨이 있어야 합니다.
nist-sp-800-190-restrict-clusteradmin-rolebindings `cluster-admin` 역할 사용을 제한합니다.
nist-sp-800-190-block-secrets-of-type-basic-auth 기본 인증 유형 보안 비밀을 제한합니다. CM-6 구성 설정
nist-sp-800-190-enforce-config-management 클러스터에 하나 이상의 `RootSync` 객체가 있는 구성 동기화가 실행 중이고 드리프트 방지가 사용 설정되어 있어야 합니다.
nist-sp-800-190-require-binauthz 허용 웹훅 검증을 위한 Binary Authorization이 필요합니다.
nist-sp-800-190-require-managed-by-label 모든 앱에 유효한 `app.kubernetes.io/managed-by` 라벨이 있어야 합니다.
nist-sp-800-190-restrict-hostpath-volumes HostPath 볼륨의 사용을 제한합니다.
nist-sp-800-190-restrict-volume-types 마운트 가능한 볼륨 유형을 허용된 목록으로 제한합니다.
nist-sp-800-190-apparmor 포드에 허용되는 AppArmor 프로필을 제한합니다. CM-7 최소 기능
nist-sp-800-190-capabilities 포드에 허용되는 추가 기능을 제한합니다.
nist-sp-800-190-host-namespaces `hostPID` 또는 `hostIPC`를 `true`로 설정하여 컨테이너를 제한합니다.
nist-sp-800-190-host-network `hostNetwork` 플래그를 `true`로 설정하여 컨테이너가 실행되지 않도록 제한합니다.
nist-sp-800-190-privileged-containers `securityContext.privileged`를 `true`로 설정하여 컨테이너를 제한합니다.
nist-sp-800-190-proc-mount-type 포드에 기본 `/proc` 마스크가 필요합니다.
nist-sp-800-190-restrict-clusteradmin-rolebindings `cluster-admin` 역할 사용을 제한합니다.
nist-sp-800-190-restrict-hostpath-volumes HostPath 볼륨의 사용을 제한합니다.
nist-sp-800-190-restrict-volume-types 마운트 가능한 볼륨 유형을 허용된 목록으로 제한합니다.
nist-sp-800-190-seccomp Seccomp 프로필을 `Unconfined`로 명시적으로 설정하지 않아야 합니다.
nist-sp-800-190-selinux 포드의 SELinux 구성을 제한합니다.
nist-sp-800-190-sysctls 포드에 허용되는 Sysctl을 제한합니다.
nist-sp-800-190-enforce-config-management 클러스터에 하나 이상의 `RootSync` 객체가 있는 구성 동기화가 실행 중이고 드리프트 방지가 사용 설정되어 있어야 합니다. CP-9 시스템 백업
nist-sp-800-190-require-managed-by-label 모든 앱에 유효한 `app.kubernetes.io/managed-by` 라벨이 있어야 합니다.
nist-sp-800-190-enforce-config-management 클러스터에 하나 이상의 `RootSync` 객체가 있는 구성 동기화가 실행 중이고 드리프트 방지가 사용 설정되어 있어야 합니다. CP-10 정보 시스템 복구 및 재구성
nist-sp-800-190-require-managed-by-label 모든 앱에 유효한 `app.kubernetes.io/managed-by` 라벨이 있어야 합니다.
nist-sp-800-190-restrict-rbac-subjects RBAC 주제에서 이름 사용을 허용된 값으로 제한합니다. IA-2 식별 및 인증(조직 사용자)
nist-sp-800-190-block-creation-with-default-serviceaccount 기본 서비스 계정을 사용한 리소스 생성을 제한합니다. IA-4 식별자 관리
nist-sp-800-190-restrict-rbac-subjects RBAC 주제에서 이름 사용을 허용된 값으로 제한합니다.
nist-sp-800-190-require-binauthz 허용 웹훅 검증을 위한 Binary Authorization이 필요합니다. IA-5 인증자 관리
nist-sp-800-190-restrict-rbac-subjects RBAC 주제에서 이름 사용을 허용된 값으로 제한합니다.
nist-sp-800-190-restrict-rbac-subjects RBAC 주제에서 이름 사용을 허용된 값으로 제한합니다. MA-4 비로컬 유지보수
nist-sp-800-190-enforce-config-management 클러스터에 하나 이상의 `RootSync` 객체가 있는 구성 동기화가 실행 중이고 드리프트 방지가 사용 설정되어 있어야 합니다. SA-10 개발자 구성 관리
nist-sp-800-190-require-managed-by-label 모든 앱에 유효한 `app.kubernetes.io/managed-by` 라벨이 있어야 합니다.
nist-sp-800-190-require-namespace-network-policies 클러스터에 정의된 모든 네임스페이스에 NetworkPolicy가 있어야 합니다. 공유 리소스의 SC-4 정보
nist-sp-800-190-cpu-and-memory-limits-required 포드에 CPU 및 메모리 한도를 지정해야 합니다. SC-6 리소스 가용성
nist-sp-800-190-asm-peer-authn-strict-mtls PeerAuthentications로 엄격한 mTLS를 덮어쓸 수 없습니다. SC-8 전송 비밀유지 및 무결성
nist-sp-800-190-block-secrets-of-type-basic-auth 기본 인증 유형 보안 비밀을 제한합니다. SI-7 소프트웨어, 펌웨어 및 정보 무결성
nist-sp-800-190-enforce-config-management 클러스터에 하나 이상의 `RootSync` 객체가 있는 구성 동기화가 실행 중이고 드리프트 방지가 사용 설정되어 있어야 합니다.
nist-sp-800-190-require-binauthz 허용 웹훅 검증을 위한 Binary Authorization이 필요합니다.
nist-sp-800-190-require-managed-by-label 모든 앱에 유효한 `app.kubernetes.io/managed-by` 라벨이 있어야 합니다.
nist-sp-800-190-restrict-hostpath-volumes HostPath 볼륨의 사용을 제한합니다.

시작하기 전에

  1. 이 안내에서 사용되는 gcloud, kubectl 명령어를 제공하는 Google Cloud CLI를 설치하고 초기화합니다. Cloud Shell을 사용하는 경우 Google Cloud CLI가 사전 설치됩니다.
  2. 제약조건 템플릿의 기본 라이브러리를 사용하여 클러스터에 정책 컨트롤러를 설치합니다. 이 번들에는 참조 제약조건이 포함되어 있으므로 참조 제약조건에 대한 지원을 사용 설정해야 합니다.

참조 제약조건에 맞게 정책 컨트롤러 구성

  1. 다음 YAML 매니페스트를 파일에 policycontroller-config.yaml로 저장합니다. 이 매니페스트는 특정 종류의 객체를 감시하도록 정책 컨트롤러를 구성합니다.

    apiVersion: config.gatekeeper.sh/v1alpha1
    kind: Config
    metadata:
      name: config
      namespace: "gatekeeper-system"
    spec:
      sync:
        syncOnly:
          - group: "networking.k8s.io"
            version: "v1"
            kind: "NetworkPolicy"
          - group: "configsync.gke.io"
            version: "v1beta1"
            kind: "RootSync"
          - group: "admissionregistration.k8s.io"
            version: "v1"
            kind: "ValidatingWebhookConfiguration"
    
  2. policycontroller-config.yaml 매니페스트를 적용합니다.

    kubectl apply -f policycontroller-config.yaml
    

클러스터 및 워크로드 구성

  1. nist-sp-800-190-enforce-config-management에서는 드리프트 방지 허용 웹훅을 포함한 구성 동기화의 사용 설정 및 구성이 필요합니다.
  2. 컨테이너 이미지는 허용된 저장소 목록으로 제한되며, nist-sp-800-190-restrict-repos에서 필요한 경우 맞춤설정할 수 있습니다.
  3. 노드는 nist-sp-800-190-nodes-have-consistent-time에서 이미지에 대해 Container-Optimized OS 또는 Ubuntu를 사용해야 합니다.
  4. nist-sp-800-190-require-binauthz에서 Binary Authorization을 사용 설정하고 구성해야 합니다.

NIST SP 800-190 정책 번들 감사

정책 컨트롤러를 사용하면 Kubernetes 클러스터에 정책을 적용할 수 있습니다. 앞의 테이블에서 설명된 NIST 정책과 관련하여 워크로드 및 규정 준수를 테스트하는 데 도움이 되도록, '감사' 모드에서 이러한 제약조건을 배포하여 위반 사항을 표시할 수 있고 더 중요하게는 Kubernetes 클러스터에 적용하기 전에 문제를 해결할 기회를 가질 수 있습니다.

kubectl, kpt 또는 구성 동기화를 사용하여 dryrun으로 설정된 spec.enforcementAction으로 이러한 정책을 적용할 수 있습니다.

kubectl

  1. (선택사항) kubectl을 사용하여 정책 제약조건을 미리 봅니다.

    kubectl kustomize https://github.com/GoogleCloudPlatform/gke-policy-library.git/anthos-bundles/nist-sp-800-190
    
  2. kubectl을 사용하여 정책 제약조건을 적용합니다.

    kubectl apply -k https://github.com/GoogleCloudPlatform/gke-policy-library.git/anthos-bundles/nist-sp-800-190
    

    출력은 다음과 같습니다.

    asmpeerauthnstrictmtls.constraints.gatekeeper.sh/nist-sp-800-190-asm-peer-authn-strict-mtls created
    k8sallowedrepos.constraints.gatekeeper.sh/nist-sp-800-190-restrict-repos created
    k8sblockcreationwithdefaultserviceaccount.constraints.gatekeeper.sh/nist-sp-800-190-block-creation-with-default-serviceaccount created
    k8sblockobjectsoftype.constraints.gatekeeper.sh/nist-sp-800-190-block-secrets-of-type-basic-auth created
    k8senforceconfigmanagement.constraints.gatekeeper.sh/nist-sp-800-190-enforce-config-management created
    k8spspapparmor.constraints.gatekeeper.sh/nist-sp-800-190-apparmor created
    k8spspcapabilities.constraints.gatekeeper.sh/nist-sp-800-190-capabilities created
    k8spspforbiddensysctls.constraints.gatekeeper.sh/nist-sp-800-190-sysctls created
    k8spsphostfilesystem.constraints.gatekeeper.sh/nist-sp-800-190-restrict-hostpath-volumes created
    k8spsphostnamespace.constraints.gatekeeper.sh/nist-sp-800-190-host-namespaces created
    k8spsphostnetworkingports.constraints.gatekeeper.sh/nist-sp-800-190-host-network created
    k8spspprivilegedcontainer.constraints.gatekeeper.sh/nist-sp-800-190-privileged-containers created
    k8spspprocmount.constraints.gatekeeper.sh/nist-sp-800-190-proc-mount-type created
    k8spspselinuxv2.constraints.gatekeeper.sh/nist-sp-800-190-selinux created
    k8spspseccomp.constraints.gatekeeper.sh/nist-sp-800-190-seccomp created
    k8spspvolumetypes.constraints.gatekeeper.sh/nist-sp-800-190-restrict-volume-types created
    k8sprohibitrolewildcardaccess.constraints.gatekeeper.sh/nist-sp-800-190-restrict-role-wildcards created
    k8srequirebinauthz.constraints.gatekeeper.sh/nist-sp-800-190-require-binauthz created
    k8srequirecosnodeimage.constraints.gatekeeper.sh/nist-sp-800-190-nodes-have-consistent-time created
    k8srequirenamespacenetworkpolicies.constraints.gatekeeper.sh/nist-sp-800-190-require-namespace-network-policies created
    k8srequiredlabels.constraints.gatekeeper.sh/nist-sp-800-190-require-managed-by-label created
    k8srequiredresources.constraints.gatekeeper.sh/nist-sp-800-190-cpu-and-memory-limits-required created
    k8srestrictrbacsubjects.constraints.gatekeeper.sh/nist-sp-800-190-restrict-rbac-subjects created
    k8srestrictrolebindings.constraints.gatekeeper.sh/nist-sp-800-190-restrict-clusteradmin-rolebindings created
    
  3. 정책 제약조건이 설치되었는지 확인하고 클러스터 전체에 위반 사항이 있는지 확인합니다.

    kubectl get constraints -l policycontroller.gke.io/bundleName=nist-sp-800-190
    

    출력은 다음과 비슷합니다.

    NAME                                                            ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8spspapparmor.constraints.gatekeeper.sh/nist-sp-800-190-apparmor   dryrun               0
    
    NAME                                                                        ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8srequirebinauthz.constraints.gatekeeper.sh/nist-sp-800-190-require-binauthz   dryrun               0
    
    NAME                                                                                   ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8srestrictrbacsubjects.constraints.gatekeeper.sh/nist-sp-800-190-restrict-rbac-subjects   dryrun               0
    
    NAME                                                                   ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8spspforbiddensysctls.constraints.gatekeeper.sh/nist-sp-800-190-sysctls   dryrun               0
    
    NAME                                                                            ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8spspvolumetypes.constraints.gatekeeper.sh/nist-sp-800-190-restrict-volume-types   dryrun               0
    
    NAME                                                                           ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8spsphostnetworkingports.constraints.gatekeeper.sh/nist-sp-800-190-host-network   dryrun               0
    
    NAME                                                                        ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8spsphostnamespace.constraints.gatekeeper.sh/nist-sp-800-190-host-namespaces   dryrun               0
    
    NAME                                                                                          ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8sprohibitrolewildcardaccess.constraints.gatekeeper.sh/nist-sp-800-190-restrict-role-wildcards   dryrun               0
    
    NAME                                                                                                                         ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8sblockcreationwithdefaultserviceaccount.constraints.gatekeeper.sh/nist-sp-800-190-block-creation-with-default-serviceaccount   dryrun               0
    
    NAME                                                                                   ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8spsphostfilesystem.constraints.gatekeeper.sh/nist-sp-800-190-restrict-hostpath-volumes   dryrun               0
    
    NAME                                                          ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8spspseccomp.constraints.gatekeeper.sh/nist-sp-800-190-seccomp   dryrun               0
    
    NAME                                                                                      ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    asmpeerauthnstrictmtls.constraints.gatekeeper.sh/nist-sp-800-190-asm-peer-authn-strict-mtls   dryrun               0
    
    NAME                                                                                        ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8srequiredresources.constraints.gatekeeper.sh/nist-sp-800-190-cpu-and-memory-limits-required   dryrun               0
    
    NAME                                                                    ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8spspprocmount.constraints.gatekeeper.sh/nist-sp-800-190-proc-mount-type   dryrun               0
    
    NAME                                                                                           ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8sblockobjectsoftype.constraints.gatekeeper.sh/nist-sp-800-190-block-secrets-of-type-basic-auth   dryrun               0
    
    NAME                                                                                                          ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8srequirenamespacenetworkpolicies.constraints.gatekeeper.sh/nist-sp-800-190-require-namespace-network-policies   dryrun               0
    
    NAME                                                                    ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8spspcapabilities.constraints.gatekeeper.sh/nist-sp-800-190-capabilities   dryrun               0
    
    NAME                                                                               ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8srequiredlabels.constraints.gatekeeper.sh/nist-sp-800-190-require-managed-by-label   dryrun               0
    
    NAME                                                                                    ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8spspprivilegedcontainer.constraints.gatekeeper.sh/nist-sp-800-190-privileged-containers   dryrun               0
    
    NAME                                                                   ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8sallowedrepos.constraints.gatekeeper.sh/nist-sp-800-190-restrict-repos   dryrun               0
    
    NAME                                                            ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8spspselinuxv2.constraints.gatekeeper.sh/nist-sp-800-190-selinux   dryrun               0
    
    NAME                                                                                         ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8senforceconfigmanagement.constraints.gatekeeper.sh/nist-sp-800-190-enforce-config-management   dryrun               0
    
    NAME                                                                                               ENFORCEMENT-ACTION   TOTAL-VIOLATIONS
    k8srestrictrolebindings.constraints.gatekeeper.sh/nist-sp-800-190-restrict-clusteradmin-rolebindings   dryrun               0
    

kpt

  1. kpt를 설치하고 설정합니다.

    kpt는 이 안내에서 Kubernetes 리소스를 맞춤설정하고 배포하는 데 사용됩니다.

  2. kpt를 사용하여 GitHub에서 NIST SP 800-190 정책 번들을 다운로드합니다.

    kpt pkg get https://github.com/GoogleCloudPlatform/gke-policy-library.git/anthos-bundles/nist-sp-800-190
    
  3. set-enforcement-action kpt 함수를 실행하여 정책의 시정 조치를 dryrun으로 설정합니다.

    kpt fn eval nist-sp-800-190 -i gcr.io/kpt-fn/set-enforcement-action:v0.1 \
    -- enforcementAction=dryrun
    
  4. 변경사항을 추적하는 리소스를 만드는 kpt로 작업 디렉터리를 초기화합니다.

    cd nist-sp-800-190 kpt live init
    
  5. kpt로 정책 제약조건을 적용합니다.

    kpt live apply
    
  6. 정책 제약조건이 설치되었는지 확인하고 클러스터 전체에 위반 사항이 있는지 확인합니다.

    kpt live status --output table --poll-until current
    

    CURRENT 상태는 제약조건이 성공적으로 설치되었음을 확인합니다.

구성 동기화

  1. kpt를 설치하고 설정합니다.

    이 안내에서는 kpt를 사용하여 Kubernetes 리소스를 맞춤설정하고 배포합니다.

    구성 동기화를 사용하여 클러스터에 정책을 배포하는 운영자는 다음 안내를 따르세요.

  2. 구성 동기화의 동기화 디렉터리로 변경합니다.

    cd SYNC_ROOT_DIR
    

    resourcegroup.yaml.gitignore를 만들거나 추가하려면 다음 안내를 따르세요.

    echo resourcegroup.yaml >> .gitignore
    
  3. 전용 policies 디렉터리를 만듭니다.

    mkdir -p policies
    
  4. kpt를 사용하여 GitHub에서 NIST SP 800-190 정책 번들을 다운로드합니다.

    kpt pkg get https://github.com/GoogleCloudPlatform/gke-policy-library.git/anthos-bundles/nist-sp-800-190 policies/nist-sp-800-190
    
  5. set-enforcement-action kpt 함수를 실행하여 정책의 시정 조치를 dryrun으로 설정합니다.

    kpt fn eval policies/nist-sp-800-190 -i gcr.io/kpt-fn/set-enforcement-action:v0.1 -- enforcementAction=dryrun
    
  6. (선택사항) 생성될 정책 제약조건을 미리 봅니다.

    kpt live init policies/nist-sp-800-190 kpt live apply --dry-run policies/nist-sp-800-190
    
  7. 구성 동기화의 동기화 디렉터리에 Kustomize가 사용되는 경우 루트 kustomization.yamlpolicies/nist-sp-800-190을 추가합니다. 그렇지 않으면 policies/nist-sp-800-190/kustomization.yaml 파일을 삭제합니다.

    rm SYNC_ROOT_DIR/policies/nist-sp-800-190/kustomization.yaml
    
  8. 구성 동기화 저장소에 변경사항을 푸시합니다.

    git add SYNC_ROOT_DIR/policies/nist-sp-800-190 git commit -m 'Adding NIST SP 800-190 policy audit enforcement'
    git push
    
  9. 설치 상태를 확인합니다.

    watch gcloud beta container fleet config-management status --project PROJECT_ID
    

    SYNCED 상태는 정책 설치를 확인합니다.

정책 위반 보기

정책 제약조건이 감사 모드로 설치되면 정책 컨트롤러 대시보드를 사용하여 UI에서 클러스터 위반을 볼 수 있습니다.

  1. 또한 kubectl을 사용하여 다음 명령어로 클러스터에서 위반 항목을 볼 수 있습니다.

    kubectl get constraint -l policycontroller.gke.io/bundleName=nist-sp-800-190 -o json | jq -cC '.items[]| [.metadata.name,.status.totalViolations]'
    
  2. 위반이 있는 경우 제약조건당 위반 메시지 목록을 다음에서 볼 수 있습니다.

    kubectl get constraint -l policycontroller.gke.io/bundleName=nist-sp-800-190 -o json | jq -C '.items[]| select(.status.totalViolations>0)| [.metadata.name,.status.violations[]?]'
    

NIST SP 800-190 정책 번들 시정 조치 변경

클러스터에서 정책 위반을 검토한 후에는 허용 컨트롤러가 호환되지 않는 리소스가 클러스터에 적용되지 않도록 warn 또는 deny를 수행할 수 있도록 시행 모드 변경을 고려할 수 있습니다.

kubectl

  1. kubectl을 사용하여 정책의 시행 작업을 deny로 설정합니다.

    kubectl get constraints -l policycontroller.gke.io/bundleName=nist-sp-800-190 -o name | xargs -I {} kubectl patch {} --type='json' -p='[{"op":"replace","path":"/spec/enforcementAction","value":"warn"}]'
    
  2. 정책 제약조건 시행 작업이 업데이트되었는지 확인합니다.

    kubectl get constraints -l policycontroller.gke.io/bundleName=nist-sp-800-190
    

kpt

  1. set-enforcement-action kpt 함수를 실행하여 정책의 시정 조치를 deny으로 설정합니다.

    kpt fn eval -i gcr.io/kpt-fn/set-enforcement-action:v0.1 -- enforcementAction=deny
    
  2. 정책 제약조건을 적용합니다.

    kpt live apply
    

구성 동기화

구성 동기화를 사용하여 클러스터에 정책을 배포하는 운영자는 다음 안내를 따르세요.

  1. 구성 동기화의 동기화 디렉터리로 변경합니다.

    cd SYNC_ROOT_DIR
    
  2. set-enforcement-action kpt 함수를 실행하여 정책의 시정 조치를 deny으로 설정합니다.

    kpt fn eval policies/nist-sp-800-190 -i gcr.io/kpt-fn/set-enforcement-action:v0.1 -- enforcementAction=deny
    
  3. 구성 동기화 저장소에 변경사항을 푸시합니다.

    git add SYNC_ROOT_DIR/policies/nist-sp-800-190
    git commit -m 'Adding NIST SP 800-190 policy warn enforcement'
    git push
    
  4. 설치 상태를 확인합니다.

    gcloud alpha anthos config sync repo list --project PROJECT_ID
    

    SYNCED 열에 표시된 저장소는 정책 설치를 확인합니다.

테스트 정책 시행

다음 명령어를 사용하여 클러스터에 정책을 준수하지 않는 리소스를 만듭니다.

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
  name: wp-non-compliant
spec:
  containers:
    ‐ image: wordpress
      name: wordpress
EOF

다음 예시와 같이 허용 컨트롤러는 이 리소스가 위반하는 정책 위반을 나열하는 경고를 생성해야 합니다.

Warning: [nist-sp-800-190-cpu-and-memory-limits-required] container <wordpress> does not have <{"cpu", "memory"}> limits defined
Warning: [nist-sp-800-190-restrict-repos] container <wordpress> has an invalid image repo <wordpress>, allowed repos are ["gcr.io/gke-release/", "gcr.io/anthos-baremetal-release/", "gcr.io/config-management-release/", "gcr.io/kubebuilder/", "gcr.io/gkeconnect/", "gke.gcr.io/"]
pod/wp-non-compliant created

NIST SP 800-190 정책 번들 삭제

필요한 경우 클러스터에서 NIST SP 800-190 정책 번들을 삭제할 수 있습니다.

kubectl

  • kubectl을 사용하여 정책을 삭제합니다.

    kubectl delete constraint -l policycontroller.gke.io/bundleName=nist-sp-800-190
    

kpt

  • 정책을 삭제합니다.

    kpt live destroy
    

구성 동기화

구성 동기화를 사용하여 클러스터에 정책을 배포하는 운영자는 다음 안내를 따르세요.

  1. 구성 동기화 저장소에 변경사항을 푸시합니다.

    git rm -r SYNC_ROOT_DIR/policies/nist-sp-800-190
    git commit -m 'Removing NIST SP 800-190 policies'
    git push
    
  2. 상태를 확인합니다.

    gcloud alpha anthos config sync repo list --project PROJECT_ID
    

    SYNCED 열에 표시된 저장소는 정책 삭제를 확인합니다.