×

本节描述安全内容的生命周期,包括如何使用更新版本的合规性内容以及如何创建自定义ProfileBundle对象。

ProfileBundle CR 示例

ProfileBundle对象需要两条信息:包含contentImage的容器镜像的URL以及包含合规性内容的文件。contentFile参数相对于文件系统的根目录。您可以定义内置的rhcos4 ProfileBundle对象,如下例所示

apiVersion: compliance.openshift.io/v1alpha1
kind: ProfileBundle
metadata:
  creationTimestamp: "2022-10-19T12:06:30Z"
  finalizers:
  - profilebundle.finalizers.compliance.openshift.io
  generation: 1
  name: rhcos4
  namespace: openshift-compliance
  resourceVersion: "46741"
  uid: 22350850-af4a-4f5c-9a42-5e7b68b82d7d
spec:
  contentFile: ssg-rhcos4-ds.xml (1)
  contentImage: registry.redhat.io/compliance/openshift-compliance-content-rhel8@sha256:900e... (2)
status:
  conditions:
  - lastTransitionTime: "2022-10-19T12:07:51Z"
    message: Profile bundle successfully parsed
    reason: Valid
    status: "True"
    type: Ready
  dataStreamStatus: VALID
1 包含合规性内容的文件位置。
2 内容镜像位置。

内容镜像使用的基础镜像必须包含coreutils

更新安全内容

安全内容包含在ProfileBundle对象引用的容器镜像中。为了准确跟踪对ProfileBundles和从捆绑包解析的自定义资源(如规则或配置文件)的更新,请使用摘要而不是标签来标识包含合规性内容的容器镜像

$ oc -n openshift-compliance get profilebundles rhcos4 -oyaml
示例输出
apiVersion: compliance.openshift.io/v1alpha1
kind: ProfileBundle
metadata:
  creationTimestamp: "2022-10-19T12:06:30Z"
  finalizers:
  - profilebundle.finalizers.compliance.openshift.io
  generation: 1
  name: rhcos4
  namespace: openshift-compliance
  resourceVersion: "46741"
  uid: 22350850-af4a-4f5c-9a42-5e7b68b82d7d
spec:
  contentFile: ssg-rhcos4-ds.xml
  contentImage: registry.redhat.io/compliance/openshift-compliance-content-rhel8@sha256:900e... (1)
status:
  conditions:
  - lastTransitionTime: "2022-10-19T12:07:51Z"
    message: Profile bundle successfully parsed
    reason: Valid
    status: "True"
    type: Ready
  dataStreamStatus: VALID
1 安全容器镜像。

每个ProfileBundle都由一个部署支持。当合规性运算符检测到容器镜像摘要已更改时,部署将更新以反映更改并再次解析内容。使用摘要而不是标签可确保您使用稳定且可预测的配置文件集。

其他资源