1.2. 使用 RHACM 安装 OpenShift Data Foundation 逻辑卷管理器 Operator


OpenShift Data Foundation 逻辑卷管理器 Operator 使用 Red Hat Advanced Cluster Management for Kubernetes(RHACM)在单一节点 OpenShift(SNO)集群上部署。在将 Operator 应用到与 PlacementRule 中指定的选择器匹配的受管集群时,您在 RHACM 上创建 Policy。该策略也应用于稍后导入并满足 PlacementRule 的集群。

先决条件

  • 使用具有 cluster-admin 和 operator 安装权限的账户访问 RHACM 集群。
  • 每个 SNO 集群中专用磁盘,供 OpenShift Data Foundation 逻辑卷管理器 Operator 使用。
注意

确保 SNO 集群中没有安装其他存储置备程序。OpenShift Data Foundation Logical Volume Manager Operator 应该是唯一的存储置备程序,因为它使用节点上的所有可用磁盘。

流程

  1. 使用您的 OpenShift 凭证登录 RHACM CLI。

    如需更多信息,请参阅安装 Red Hat Advanced Cluster Management for Kubernetes

  2. 创建要在其中创建策略的命名空间。

    # oc create ns lvm-policy-ns
    Copy to Clipboard Toggle word wrap
  3. 将以下 YAML 保存到带有名称(如 policy-lvm-operator.yaml )的文件,以创建策略。

    # This policy verifies the installation of the official version of the {product-name-short}
    # Logical Volume Manager Operator on the managed clusters.
    # If set to "enforce" it installs the operator.
    # Used APIs: OLM, ODF-LVMO #https://github.com/operator-framework/operator-lifecycle-manager
    # https://github.com/red-hat-storage/lvm-operator
    
    apiVersion: apps.open-cluster-management.io/v1
    kind: PlacementRule
    metadata:
      name: placement-install-odf-lvm-operator
    spec:
      clusterConditions:
      - status: "True"
        type: ManagedClusterConditionAvailable
      clusterSelector:
        matchExpressions:
        - key: vendor
          operator: In
          values:
          - OpenShift
    ---
    apiVersion: policy.open-cluster-management.io/v1
    kind: PlacementBinding
    metadata:
      name: binding-install-odf-lvm-operator
    placementRef:
      apiGroup: apps.open-cluster-management.io
      kind: PlacementRule
      name: placement-install-odf-lvm-operator
    subjects:
    - apiGroup: policy.open-cluster-management.io
      kind: Policy
      name: install-odf-lvm-operator
    ---
    apiVersion: policy.open-cluster-management.io/v1
    kind: Policy
    metadata:
      annotations:
        policy.open-cluster-management.io/categories: CM Configuration Management
        policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
        policy.open-cluster-management.io/standards: NIST SP 800-53
      name: install-odf-lvm-operator
    spec:
      disabled: false
      remediationAction: enforce
      policy-templates:
      - objectDefinition:
          apiVersion: policy.open-cluster-management.io/v1
          kind: ConfigurationPolicy
          metadata:
            name: install-odf-lvm-operator
          spec:
            object-templates:
            - complianceType: musthave
              objectDefinition:
                apiVersion: v1
                kind: Namespace
                metadata:
                  labels:
                    openshift.io/cluster-monitoring: "true"
                    pod-security.kubernetes.io/enforce: privileged
                    pod-security.kubernetes.io/audit: privileged
                    pod-security.kubernetes.io/warn: privileged
                  name: openshift-storage
            - complianceType: musthave
              objectDefinition:
                apiVersion: operators.coreos.com/v1
                kind: OperatorGroup
                metadata:
                  name: openshift-storage-operatorgroup
                  namespace: openshift-storage
                spec:
                  targetNamespaces:
                  - openshift-storage
            - complianceType: musthave
              objectDefinition:
                apiVersion: operators.coreos.com/v1alpha1
                kind: Subscription
                metadata:
                  name: odf-lvm-operator
                  namespace: openshift-storage
                spec:
                  installPlanApproval: Automatic
                  name: odf-lvm-operator
                  source: redhat-operators
                  sourceNamespace: openshift-marketplace
            remediationAction: enforce
            severity: low
      - objectDefinition:
          apiVersion: policy.open-cluster-management.io/v1
          kind: ConfigurationPolicy
          metadata:
            name: odf-lvmcluster
          spec:
            object-templates:
               - complianceType: musthave
                 objectDefinition:
                   apiVersion: lvm.topolvm.io/v1alpha1
                   kind: LVMCluster
                   metadata:
                     name: odf-lvmcluster
                     namespace: openshift-storage
                   spec:
                     storage:
                       deviceClasses:
                       - name: vg1
                         thinPoolConfig:
                           name: thin-pool-1
                           sizePercent: 90
                           overprovisionRatio: 10
            remediationAction: enforce
            severity: low
    Copy to Clipboard Toggle word wrap
  4. 运行以下命令在命名空间中创建策略:

    # oc create -f policy-lvm-operator.yaml -n lvm-policy-ns
    Copy to Clipboard Toggle word wrap

    其中,policy-lvm-operator.yaml 是用于保存策略的文件的名称。

    这会在命名空间 lvm-policy-ns 中创建一个 PolicyPlacementRulePlacementBindingPolicy 会在与放置规则(PlacementRule)匹配的集群中创建 Namespace, OperatorGroup, Subscription, 和 LVMCluster 资源。这会在与选择条件匹配的 SNO 集群上部署 Operator,并将其配置为设置所需资源以置备存储。在安装后,Operator 会使用所有未使用的磁盘。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat