이름과 채널을 참조하는 서브스크립션(container-security-operator)을 생성하는 정책입니다. 이 구성 정책에는 리소스를 생성하기 위해 적용되는 spec.remediationAction 이 설정되어 있어야 합니다. 서브스크립션은 서브스크립션이 지원하는 컨테이너로 프로필을 가져옵니다. 다음 예제를 확인합니다.
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:
name: policy-imagemanifestvuln-example-sub
spec:
remediationAction: enforce # will be overridden by remediationAction in parent policy
severity: high
object-templates:
- complianceType: musthave
objectDefinition:
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: container-security-operator
namespace: openshift-operators
spec:
# channel: quay-v3.3 # specify a specific channel if desired
installPlanApproval: Automatic
name: container-security-operator
source: redhat-operators
sourceNamespace: openshift-marketplace
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:name: policy-imagemanifestvuln-example-sub
spec:remediationAction: enforce # will be overridden by remediationAction in parent policyseverity: high
object-templates:-complianceType: musthave
objectDefinition:apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:name: container-security-operator
namespace: openshift-operators
spec:# channel: quay-v3.3 # specify a specific channel if desiredinstallPlanApproval: Automatic
name: container-security-operator
source: redhat-operators
sourceNamespace: openshift-marketplace
Copy to ClipboardCopied!Toggle word wrapToggle overflow
컨테이너 보안 Operator 설치에 성공했는지 확인하기 위해 ClusterServiceVersion 을 감사하는 정보 구성 정책입니다. 다음 예제를 확인합니다.
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:
name: policy-imagemanifestvuln-status
spec:
remediationAction: inform # will be overridden by remediationAction in parent policy
severity: high
object-templates:
- complianceType: musthave
objectDefinition:
apiVersion: operators.coreos.com/v1alpha1
kind: ClusterServiceVersion
metadata:
namespace: openshift-operators
spec:
displayName: Red Hat Quay Container Security Operator
status:
phase: Succeeded # check the CSV status to determine if operator is running or not
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:name: policy-imagemanifestvuln-status
spec:remediationAction: inform # will be overridden by remediationAction in parent policyseverity: high
object-templates:-complianceType: musthave
objectDefinition:apiVersion: operators.coreos.com/v1alpha1
kind: ClusterServiceVersion
metadata:namespace: openshift-operators
spec:displayName: Red Hat Quay Container Security Operator
status:phase: Succeeded # check the CSV status to determine if operator is running or not
Copy to ClipboardCopied!Toggle word wrapToggle overflow
이미지 취약점 검사에 의해 ImageManifestVuln 오브젝트가 생성되었는지 여부를 감사하는 정보 구성 정책입니다. 다음 예제를 확인합니다.
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:
name: policy-imagemanifestvuln-example-imv
spec:
remediationAction: inform # will be overridden by remediationAction in parent policy
severity: high
namespaceSelector:
exclude: ["kube-*"]
include: ["*"]
object-templates:
- complianceType: mustnothave # mustnothave any ImageManifestVuln object
objectDefinition:
apiVersion: secscan.quay.redhat.com/v1alpha1
kind: ImageManifestVuln # checking for a Kind
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:name: policy-imagemanifestvuln-example-imv
spec:remediationAction: inform # will be overridden by remediationAction in parent policyseverity: high
namespaceSelector:exclude:["kube-*"]include:["*"]object-templates:-complianceType: mustnothave # mustnothave any ImageManifestVuln objectobjectDefinition:apiVersion: secscan.quay.redhat.com/v1alpha1
kind: ImageManifestVuln # checking for a Kind
Copy to ClipboardCopied!Toggle word wrapToggle overflow
etcd 암호화 정책을 적용하여 ETCD 데이터 저장소에서 중요한 데이터의 암호화를 감지하거나 활성화합니다. Kubernetes 구성 정책 컨트롤러는 etcd-encryption 정책의 상태를 모니터링합니다. 자세한 내용은 OpenShift Container Platform 설명서의 etcd 데이터 암호화 를 참조하십시오. 참고: ETCD 암호화 정책은 Red Hat OpenShift Container Platform 4 이상만 지원합니다.
Compliance Operator는 OpenSCAP을 실행하는 Operator이며 필요한 보안 벤치마크와 함께 Red Hat OpenShift Container Platform 클러스터를 계속 준수할 수 있습니다. Compliance Operator 정책을 사용하여 관리 클러스터에 규정 준수 Operator를 설치할 수 있습니다.
규정 준수 Operator 정책은 Red Hat Advanced Cluster Management에서 Kubernetes 구성 정책으로 생성됩니다. OpenShift Container Platform 4.7 및 4.6은 규정 준수 Operator 정책을 지원합니다. 자세한 내용은 OpenShift Container Platform 설명서 의 Compliance Operator 이해를 참조하십시오.
Essential 8 (E8) 검사 정책은 마스터 및 작업자 노드에서 E8 보안 프로필을 준수하는지 확인하는 검사를 배포합니다. E8 검사 정책을 적용하려면 규정 준수 Operator를 설치해야 합니다.
E8 검사 정책은 Red Hat Advanced Cluster Management에서 Kubernetes 구성 정책으로 생성됩니다. OpenShift Container Platform 4.7 및 4.6에서는 E8 검사 정책을 지원합니다. 자세한 내용은 OpenShift Container Platform 설명서의 Compliance Operator 이해를 참조하십시오.
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:
name: compliance-suite-e8
spec:
remediationAction: inform
severity: high
object-templates:
- complianceType: musthave # this template checks if scan has completed by checking the status field
objectDefinition:
apiVersion: compliance.openshift.io/v1alpha1
kind: ScanSettingBinding
metadata:
name: e8
namespace: openshift-compliance
profiles:
- apiGroup: compliance.openshift.io/v1alpha1
kind: Profile
name: ocp4-e8
- apiGroup: compliance.openshift.io/v1alpha1
kind: Profile
name: rhcos4-e8
settingsRef:
apiGroup: compliance.openshift.io/v1alpha1
kind: ScanSetting
name: default
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:name: compliance-suite-e8
spec:remediationAction: inform
severity: high
object-templates:-complianceType: musthave # this template checks if scan has completed by checking the status fieldobjectDefinition:apiVersion: compliance.openshift.io/v1alpha1
kind: ScanSettingBinding
metadata:name: e8
namespace: openshift-compliance
profiles:-apiGroup: compliance.openshift.io/v1alpha1
kind: Profile
name: ocp4-e8
-apiGroup: compliance.openshift.io/v1alpha1
kind: Profile
name: rhcos4-e8
settingsRef:apiGroup: compliance.openshift.io/v1alpha1
kind: ScanSetting
name: default
Copy to ClipboardCopied!Toggle word wrapToggle overflow
status 필드를 확인하여 검사가 완료되었는지 확인하는 ComplianceSuite 리소스(compliance-suite-e8)입니다.
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:
name: compliance-suite-e8
spec:
remediationAction: inform
severity: high
object-templates:
- complianceType: musthave # this template checks if scan has completed by checking the status field
objectDefinition:
apiVersion: compliance.openshift.io/v1alpha1
kind: ComplianceSuite
metadata:
name: e8
namespace: openshift-compliance
status:
phase: DONE
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:name: compliance-suite-e8
spec:remediationAction: inform
severity: high
object-templates:-complianceType: musthave # this template checks if scan has completed by checking the status fieldobjectDefinition:apiVersion: compliance.openshift.io/v1alpha1
kind: ComplianceSuite
metadata:name: e8
namespace: openshift-compliance
status:phase: DONE
Copy to ClipboardCopied!Toggle word wrapToggle overflow
ComplianceCheckResult CR(사용자 정의 리소스)을 확인하여 검사 모음의 결과를 보고하는 ComplianceCheckResult 리소스(compliance-suite-e8-results)입니다.
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:
name: compliance-suite-e8-results
spec:
remediationAction: inform
severity: high
object-templates:
- complianceType: mustnothave # this template reports the results for scan suite: e8 by looking at ComplianceCheckResult CRs
objectDefinition:
apiVersion: compliance.openshift.io/v1alpha1
kind: ComplianceCheckResult
metadata:
namespace: openshift-compliance
labels:
compliance.openshift.io/check-status: FAIL
compliance.openshift.io/suite: e8
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:name: compliance-suite-e8-results
spec:remediationAction: inform
severity: high
object-templates:-complianceType: mustnothave # this template reports the results for scan suite: e8 by looking at ComplianceCheckResult CRsobjectDefinition:apiVersion: compliance.openshift.io/v1alpha1
kind: ComplianceCheckResult
metadata:namespace: openshift-compliance
labels:compliance.openshift.io/check-status: FAIL
compliance.openshift.io/suite: e8
Copy to ClipboardCopied!Toggle word wrapToggle overflow
참고: 자동 수정이 지원됩니다. ScanSettingBinding 리소스를 생성하기 위해 적용 되도록 수정 작업을 설정합니다.
OpenShift CIS 검사 정책은 마스터 및 작업자 노드를 확인하여 OpenShift CIS 보안 벤치마크를 준수하는 검사를 배포합니다. OpenShift CIS 정책을 적용하려면 규정 준수 Operator를 설치해야 합니다.
OpenShift CIS 검사 정책은 Red Hat Advanced Cluster Management에서 Kubernetes 구성 정책으로 생성됩니다. OpenShift Container Platform 4.9, 4.7 및 4.6은 OpenShift CIS 검사 정책을 지원합니다. 자세한 내용은 OpenShift Container Platform 설명서 의 Compliance Operator 이해를 참조하십시오.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
status 필드를 확인하여 검사가 완료되었는지 확인하는 ComplianceSuite 리소스(compliance-suite-cis)
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:
name: compliance-suite-cis
spec:
remediationAction: inform
severity: high
object-templates:
- complianceType: musthave # this template checks if scan has completed by checking the status field
objectDefinition:
apiVersion: compliance.openshift.io/v1alpha1
kind: ComplianceSuite
metadata:
name: cis
namespace: openshift-compliance
status:
phase: DONE
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:name: compliance-suite-cis
spec:remediationAction: inform
severity: high
object-templates:-complianceType: musthave # this template checks if scan has completed by checking the status fieldobjectDefinition:apiVersion: compliance.openshift.io/v1alpha1
kind: ComplianceSuite
metadata:name: cis
namespace: openshift-compliance
status:phase: DONE
Copy to ClipboardCopied!Toggle word wrapToggle overflow
ComplianceCheckResult CR(사용자 정의 리소스)을 확인하여 검사 모음의 결과를 보고하는 ComplianceCheckResult 리소스(compliance-suite-cis-results)입니다.
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:
name: compliance-suite-cis-results
spec:
remediationAction: inform
severity: high
object-templates:
- complianceType: mustnothave # this template reports the results for scan suite: cis by looking at ComplianceCheckResult CRs
objectDefinition:
apiVersion: compliance.openshift.io/v1alpha1
kind: ComplianceCheckResult
metadata:
namespace: openshift-compliance
labels:
compliance.openshift.io/check-status: FAIL
compliance.openshift.io/suite: cis
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:name: compliance-suite-cis-results
spec:remediationAction: inform
severity: high
object-templates:-complianceType: mustnothave # this template reports the results for scan suite: cis by looking at ComplianceCheckResult CRsobjectDefinition:apiVersion: compliance.openshift.io/v1alpha1
kind: ComplianceCheckResult
metadata:namespace: openshift-compliance
labels:compliance.openshift.io/check-status: FAIL
compliance.openshift.io/suite: cis
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Kyverno add network 정책은 새 네임스페이스를 생성할 때 모든 트래픽을 거부하는 default-deny 라는 새 NetworkPolicy 리소스를 구성합니다. Kyverno 정책을 사용하려면 Kyverno 컨트롤러를 설치해야 합니다. 설치 정책은 policy-install-kyverno.yaml 을 참조하십시오.
다음 섹션에서 policy-kyverno-add-network-policy 정책 구조에 대한 자세한 내용을 확인하십시오.
policy-kyverno-add-network-policy 정책은 다음 YAML 파일과 유사합니다.
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: add-networkpolicy
annotations:
policies.kyverno.io/title: Add Network Policy
policies.kyverno.io/category: Multi-Tenancy
policies.kyverno.io/subject: NetworkPolicy
policies.kyverno.io/description: >-
By default, Kubernetes allows communications across all Pods within a cluster.
The NetworkPolicy resource and a CNI plug-in that supports NetworkPolicy must be used to restrict
communications. A default NetworkPolicy should be configured for each Namespace to
default deny all ingress and egress traffic to the Pods in the Namespace. Application
teams can then configure additional NetworkPolicy resources to allow desired traffic
to application Pods from select sources. This policy will create a new NetworkPolicy resource
named `default-deny` which will deny all traffic anytime a new Namespace is created.
spec:
rules:
- name: default-deny
match:
resources:
kinds:
- Namespace
generate:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
name: default-deny
namespace: "{{request.object.metadata.name}}"
synchronize: true
data:
spec:
# select all pods in the namespace
podSelector: {}
# deny all traffic
policyTypes:
- Ingress
- Egress
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:name: add-networkpolicy
annotations:policies.kyverno.io/title: Add Network Policy
policies.kyverno.io/category: Multi-Tenancy
policies.kyverno.io/subject: NetworkPolicy
policies.kyverno.io/description:>-
By default, Kubernetes allows communications across all Pods within a cluster.
The NetworkPolicy resource and a CNI plug-in that supports NetworkPolicy must be used to restrict
communications. A default NetworkPolicy should be configured for each Namespace to
default deny all ingress and egress traffic to the Pods in the Namespace. Application
teams can then configure additional NetworkPolicy resources to allow desired traffic
to application Pods from select sources. This policy will create a new NetworkPolicy resource
named `default-deny` which will deny all traffic anytime a new Namespace is created.
spec:rules:-name: default-deny
match:resources:kinds:- Namespace
generate:apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
name: default-deny
namespace:"{{request.object.metadata.name}}"synchronize:truedata:spec:# select all pods in the namespacepodSelector:{}# deny all trafficpolicyTypes:- Ingress
- Egress
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Kyverno 추가 할당량 정책은 새 네임스페이스를 생성할 때 새 ResourceQuota 및 LimitRange 리소스를 구성합니다. Kyverno 정책을 사용하려면 Kyverno 컨트롤러를 설치해야 합니다. 설치 정책은 policy-install-kyverno.yaml 을 참조하십시오.
다음 섹션에서 policy-kyverno-add-quota 정책 구조에 대한 자세한 내용을 확인하십시오.
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: add-ns-quota
annotations:
policies.kyverno.io/title: Add Quota
policies.kyverno.io/category: Multi-Tenancy
policies.kyverno.io/subject: ResourceQuota, LimitRange
policies.kyverno.io/description: >-
To better control the number of resources that can be created in a given
Namespace and provide default resource consumption limits for Pods,
ResourceQuota and LimitRange resources are recommended.
This policy will generate ResourceQuota and LimitRange resources when
a new Namespace is created.
spec:
rules:
- name: generate-resourcequota
match:
resources:
kinds:
- Namespace
generate:
apiVersion: v1
kind: ResourceQuota
name: default-resourcequota
synchronize: true
namespace: "{{request.object.metadata.name}}"
data:
spec:
hard:
requests.cpu: '4'
requests.memory: '16Gi'
limits.cpu: '4'
limits.memory: '16Gi'
- name: generate-limitrange
match:
resources:
kinds:
- Namespace
generate:
apiVersion: v1
kind: LimitRange
name: default-limitrange
synchronize: true
namespace: "{{request.object.metadata.name}}"
data:
spec:
limits:
- default:
cpu: 500m
memory: 1Gi
defaultRequest:
cpu: 200m
memory: 256Mi
type: Container
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:name: add-ns-quota
annotations:policies.kyverno.io/title: Add Quota
policies.kyverno.io/category: Multi-Tenancy
policies.kyverno.io/subject: ResourceQuota, LimitRange
policies.kyverno.io/description:>-
To better control the number of resources that can be created in a given
Namespace and provide default resource consumption limits for Pods,
ResourceQuota and LimitRange resources are recommended.
This policy will generate ResourceQuota and LimitRange resources when
a new Namespace is created.
spec:rules:-name: generate-resourcequota
match:resources:kinds:- Namespace
generate:apiVersion: v1
kind: ResourceQuota
name: default-resourcequota
synchronize:truenamespace:"{{request.object.metadata.name}}"data:spec:hard:requests.cpu:'4'requests.memory:'16Gi'limits.cpu:'4'limits.memory:'16Gi'-name: generate-limitrange
match:resources:kinds:- Namespace
generate:apiVersion: v1
kind: LimitRange
name: default-limitrange
synchronize:truenamespace:"{{request.object.metadata.name}}"data:spec:limits:-default:cpu: 500m
memory: 1Gi
defaultRequest:cpu: 200m
memory: 256Mi
type: Container
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Kyverno 동기화 보안 정책은 기본 네임스페이스에 존재하는 regcred 라는 보안을 새 네임스페이스에 복사하고 변경 사항이 탐지될 때 시크릿을 업데이트합니다. Kyverno 정책을 사용하려면 Kyverno 컨트롤러를 설치해야 합니다. 설치 정책은 policy-install-kyverno.yaml 을 참조하십시오.
다음 섹션에서 policy-kyverno-sync-secrets 정책 구조에 대해 자세히 알아보십시오.
policy-kyverno-sync-secrets 정책은 다음 YAML 파일과 유사합니다.
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: sync-secrets
annotations:
policies.kyverno.io/title: Sync Secrets
policies.kyverno.io/category: Sample
policies.kyverno.io/subject: Secret
policies.kyverno.io/description: >-
Secrets like registry credentials often need to exist in multiple
Namespaces so Pods there have access. Manually duplicating those Secrets
is time consuming and error prone. This policy will copy a
Secret called `regcred` which exists in the `default` Namespace to
new Namespaces when they are created. It will also push updates to
the copied Secrets should the source Secret be changed.
spec:
rules:
- name: sync-image-pull-secret
match:
resources:
kinds:
- Namespace
generate:
apiVersion: v1
kind: Secret
name: regcred
namespace: "{{request.object.metadata.name}}"
synchronize: true
clone:
namespace: default
name: regcred
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:name: sync-secrets
annotations:policies.kyverno.io/title: Sync Secrets
policies.kyverno.io/category: Sample
policies.kyverno.io/subject: Secret
policies.kyverno.io/description:>-
Secrets like registry credentials often need to exist in multiple
Namespaces so Pods there have access. Manually duplicating those Secrets
is time consuming and error prone. This policy will copy a
Secret called `regcred` which exists in the `default` Namespace to
new Namespaces when they are created. It will also push updates to
the copied Secrets should the source Secret be changed.
spec:rules:-name: sync-image-pull-secret
match:resources:kinds:- Namespace
generate:apiVersion: v1
kind: Secret
name: regcred
namespace:"{{request.object.metadata.name}}"synchronize:trueclone:namespace: default
name: regcred
Copy to ClipboardCopied!Toggle word wrapToggle overflow