検索

1.4. Red Hat Advanced Cluster Management の統合

download PDF

Red Hat Advanced Cluster Management がインストールされたマルチクラスターエンジン Operator を使用している場合は、可観測性ポリシー など、より多くのマルチクラスター管理機能にアクセスできます。

統合機能については、次の要件を参照してください。

マルチクラスターエンジン Operator と Red Hat Advanced Cluster Management マルチクラスター管理については、次の手順を参照してください。

1.4.1. Red Hat Advanced Cluster Management でのマルチクラスターエンジン Operator がホストするクラスターの検出

複数の ホステッドクラスター をホストしているマルチクラスターエンジン Operator クラスターがある場合は、それらのホステッドクラスターを Red Hat Advanced Cluster Management ハブクラスターに移動して、アプリケーションライフサイクルガバナンス などの Red Hat Advanced Cluster Management 管理コンポーネントを使用して管理できます。

これらのホステッドクラスターを自動的に検出し、マネージドクラスターとしてインポートすることができます。

注記: Hosted Control Plane はマネージドマルチクラスターエンジン Operator クラスターノード上で実行されます。そのため、クラスターがホストできる Hosted Control Plane の数は、マネージドマルチクラスターエンジン Operator クラスターノードのリソースの可用性と、マネージドマルチクラスターエンジン Operator クラスターの数によって決まります。ノードまたはマネージドクラスターを追加すると、より多くの Hosted Control Plane をホストできます。

必要なアクセス権限: クラスターの管理者

1.4.1.1. 前提条件

  • 1 つ以上のマルチクラスターエンジン Operator クラスターがある。
  • ハブクラスターとして設定された Red Hat Advanced Cluster Management クラスターがある。
  • 次のコマンドを実行して clusteradm CLI をインストールする。

    curl -L https://raw.githubusercontent.com/open-cluster-management-io/clusteradm/main/install.sh | bash

1.4.1.2. マルチクラスターエンジン Operator クラスターをインポートするための Red Hat Advanced Cluster Management の設定

マルチクラスターエンジン Operator には、管理対象のハブクラスターである local-cluster があります。この local-cluster では、open-cluster-management-agent-addon namespace で次のデフォルトのアドオンが有効になっています。

  • cluster-proxy
  • managed-serviceaccount
  • work-manager
1.4.1.2.1. アドオンの設定

マルチクラスターエンジン Operator が Red Hat Advanced Cluster Management にインポートされると、Red Hat Advanced Cluster Management は、マルチクラスターエンジン Operator を管理するために、同じアドオンのセットを有効にします。

これらのアドオンを別のマルチクラスターエンジン Operator の namespace にインストールして、マルチクラスターエンジン Operator が local-cluster のアドオンを使用して自己管理できるようにし、同時に Red Hat Advanced Cluster Management がマルチクラスターエンジン Operator を管理できるようにします。次の手順を実行します。

  1. CLI を使用して Red Hat Advanced Cluster Management にログインします。
  2. addonDeploymentConfig リソースを作成し、別のアドオンインストール用 namespace を指定します。次の例を参照してください。agentInstallNamespaceopen-cluster-management-agent-addon-discovery を参照しています。

    apiVersion: addon.open-cluster-management.io/v1alpha1
    kind: addonDeploymentConfig
    metadata:
      name: addon-ns-config
      namespace: multicluster-engine
    spec:
      agentInstallNamespace: open-cluster-management-agent-addon-discovery
  3. oc apply -f <filename>.yaml を実行して、ファイルを適用します。
  4. アドオンの既存の ClusterManagementAddOn リソースを更新して、作成した addonDeploymentConfig リソースで指定されている open-cluster-management-agent-addon-discovery namespace にアドオンがインストールされるようにします。次の例を参照してください。namespace として open-cluster-management-global-set を使用しています。

    apiVersion: addon.open-cluster-management.io/v1alpha1
    kind: ClusterManagementAddOn
    metadata:
      name: work-manager
    spec:
      addonMeta:
        displayName: work-manager
      installStrategy:
        placements:
        - name: global
          namespace: open-cluster-management-global-set
          rolloutStrategy:
            type: All
        type: Placements
    1. addonDeploymentConfigsClusterManagementAddOn に追加します。以下の例を参照してください。

      apiVersion: addon.open-cluster-management.io/v1alpha1
      kind: ClusterManagementAddOn
      metadata:
        name: work-manager
      spec:
        addonMeta:
          displayName: work-manager
        installStrategy:
          placements:
          - name: global
            namespace: open-cluster-management-global-set
            rolloutStrategy:
              type: All
            configs:
            - group: addon.open-cluster-management.io
              name: addon-ns-config
              namespace: multicluster-engine
              resource: addondeploymentconfigs
          type: Placements
    2. addonDeploymentConfigmanaged-serviceaccount に追加します。以下の例を参照してください。

      apiVersion: addon.open-cluster-management.io/v1alpha1
      kind: ClusterManagementAddOn
      metadata:
        name: managed-serviceaccount
      spec:
        addonMeta:
          displayName: managed-serviceaccount
        installStrategy:
          placements:
          - name: global
            namespace: open-cluster-management-global-set
            rolloutStrategy:
              type: All
            configs:
            - group: addon.open-cluster-management.io
              name: addon-ns-config
              namespace: multicluster-engine
              resource: addondeploymentconfigs
          type: Placements
    3. cluster-proxy という名前の ClusterManagementAddOn リソースに addondeploymentconfigs 値を追加します。以下の例を参照してください。
    apiVersion: addon.open-cluster-management.io/v1alpha1
    kind: ClusterManagementAddOn
    metadata:
      name: cluster-proxy
    spec:
      addonMeta:
        displayName: cluster-proxy
      installStrategy:
        placements:
        - name: global
          namespace: open-cluster-management-global-set
          rolloutStrategy:
            type: All
          configs:
          - group: addon.open-cluster-management.io
            name: addon-ns-config
            namespace: multicluster-engine
            resource: addondeploymentconfigs
        type: Placements
  5. 次のコマンドを実行して、Red Hat Advanced Cluster Management の local-cluster 用のアドオンが、指定した namespace に再インストールされていることを確認します。

    oc get deployment -n open-cluster-management-agent-addon-discovery

    次の出力例を参照してください。

    NAME                                 READY   UP-TO-DATE   AVAILABLE    AGE
    cluster-proxy-proxy-agent             1/1     1            1           24h
    klusterlet-addon-workmgr             1/1     1            1           24h
    managed-serviceaccount-addon-agent   1/1     1            1           24h
1.4.1.2.2. KlusterletConfig リソースの作成

マルチクラスターエンジン Operator には、管理対象のハブクラスターである local-cluster があります。この local-cluster に対して、klusterlet という名前のリソースが作成されます。

マルチクラスターエンジン Operator が Red Hat Advanced Cluster Management にインポートされると、Red Hat Advanced Cluster Management は、マルチクラスターエンジン Operator を管理するために、同じ名前の klusterlet (klusterlet) をインストールします。これは、マルチクラスターエンジン Operator の local-cluster の klusterlet と競合します。

競合を回避するために、klusterlet が別の名前でインストールされるように、ManagedCluster リソースがマルチクラスターエンジン Operator クラスターのインポートに使用する KlusterletConfig リソースを作成する必要があります。次の手順を実行します。

  1. 次の例を使用して KlusterletConfig リソースを作成します。この KlusterletConfig リソースがマネージドクラスターで参照された場合、spec.installMode.noOperator.postfix フィールドの値が klusterlet 名の接尾辞として使用されます (例: klusterlet-mce-import)。

    kind: KlusterletConfig
    apiVersion: config.open-cluster-management.io/v1alpha1
    metadata:
      name: mce-import-klusterlet-config
    spec:
      installMode:
        type: noOperator
        noOperator:
           postfix: mce-import
  2. oc apply -f <filename>.yaml を実行して、ファイルを適用します。
1.4.1.2.3. バックアップと復元の設定

Red Hat Advanced Cluster Management をインストールすると、バックアップおよび復元 機能も使用できます。

障害復旧シナリオでハブクラスターが復元されると、インポートされたマルチクラスターエンジン Operator クラスターとホステッドクラスターが、新しい Red Hat Advanced Cluster Management ハブクラスターにインポートされます。

このとき、Red Hat Advanced Cluster Management ハブクラスターの復元の一環として、以前の設定を復元する必要があります。

バックアップを有効にするには、backup=true ラベルを追加します。各アドオンについて、次の手順を参照してください。

  • addon-ns-config の場合は、次のコマンドを実行します。

    oc label addondeploymentconfig addon-ns-config -n multicluster-engine cluster.open-cluster-management.io/backup=true
  • hypershift-addon-deploy-config の場合は、次のコマンドを実行します。

    oc label addondeploymentconfig hypershift-addon-deploy-config -n multicluster-engine cluster.open-cluster-management.io/backup=true
  • work-manager の場合は、次のコマンドを実行します。

    oc label clustermanagementaddon work-manager cluster.open-cluster-management.io/backup=true
  • `cluster-proxy` の場合は、次のコマンドを実行します。

    oc label clustermanagementaddon cluster-proxy cluster.open-cluster-management.io/backup=true
  • managed-serviceaccount の場合は、次のコマンドを実行します。

    oc label clustermanagementaddon managed-serviceaccount cluster.open-cluster-management.io/backup=true
  • mce-import-klusterlet-config の場合は、次のコマンドを実行します。

    oc label KlusterletConfig mce-import-klusterlet-config cluster.open-cluster-management.io/backup=true

1.4.1.3. マルチクラスターエンジン Operator の手動インポート

Red Hat Advanced Cluster Management クラスターからマルチクラスターエンジン Operator クラスターを手動でインポートするには、次の手順を実行します。

  1. Red Hat Advanced Cluster Management クラスターから、ManagedCluster リソースを手動で作成し、マルチクラスターエンジン Operator クラスターをインポートします。次のファイルの例を参照してください。

    apiVersion: cluster.open-cluster-management.io/v1
    kind: ManagedCluster
    metadata:
      annotations:
        agent.open-cluster-management.io/klusterlet-config: mce-import-klusterlet-config 1
      name: mce-a 2
    spec:
      hubAcceptsClient: true
      leaseDurationSeconds: 60
    1 1
    mce-import-klusterlet-config アノテーションは、マルチクラスターエンジン Operator に別の名前で Red Hat Advanced Cluster Management の klusterlet をインストールするために、前の手順で作成した KlusterletConfig リソースを参照します。
    2
    この例では、マルチクラスターエンジン Operator が管理する mce-a という名前クラスターをインポートします。
  2. oc apply -f <filename>.yaml を実行して、ファイルを適用します。
  3. マルチクラスターエンジン Operator クラスターの kubeconfig を参照する auto-import-secret シークレットを作成します。自動インポートシークレットを使用したクラスターのインポート に進み、自動インポートシークレットを追加して、マルチクラスターエンジン Operator の自動インポートプロセスを完了します。

    Red Hat Advanced Cluster Management クラスターのマルチクラスターエンジン Operator 管理クラスターの namespace に自動インポートシークレットを作成すると、マネージドクラスターが登録されます。

  4. 次のコマンドを実行して、ステータスを取得します。

    oc get managedcluster

    マネージドクラスターのステータスとサンプル URL を含む次の出力例を参照してください。

    NAME           HUB ACCEPTED   MANAGED CLUSTER URLS            JOINED   AVAILABLE   AGE
    local-cluster  true           https://<api.acm-hub.com:port>  True     True        44h
    mce-a          true           https://<api.mce-a.com:port>    True     True        27s

重要: インポートされたマルチクラスターエンジン Operator に対して、他の Red Hat Advanced Cluster Management アドオンを有効にしないでください。

1.4.1.4. ホステッドクラスターの検出

すべてのマルチクラスターエンジン Operator クラスターを Red Hat Advanced Cluster Management にインポートしたら、それらのマネージドマルチクラスターエンジン Operator クラスターで hypershift-addon を有効にして、ホステッドクラスターを検出する必要があります。

前の手順では、デフォルトのアドオンを別の namespace にインストールしました。同様に、マルチクラスターエンジン Operator の別の namespace に hypershift-addon をインストールして、マルチクラスターエンジン Operator の local-cluster のアドオンエージェントと Red Hat Advanced Cluster Management のエージェントが、マルチクラスターエンジン Operator で動作できるようにします。

重要: 以下のすべてのコマンドで、<managed-cluster-names> を、マルチクラスターエンジン Operator のコンマ区切りのマネージドクラスター名に置き換えてください。

  1. 次のコマンドを実行して、アドオンの agentInstallNamespace namespace を open-cluster-management-agent-addon-discovery に設定します。

    oc patch addondeploymentconfig hypershift-addon-deploy-config -n multicluster-engine --type=merge -p '{"spec":{"agentInstallNamespace":"open-cluster-management-agent-addon-discovery"}}'
  2. 次のコマンドを実行して、メトリクスを無効にし、HyperShift Operator 管理を無効にします。

    oc patch addondeploymentconfig hypershift-addon-deploy-config -n multicluster-engine --type=merge -p '{"spec":{"customizedVariables":[{"name":"disableMetrics","value": "true"},{"name":"disableHOManagement","value": "true"}]}}'
  3. 次のコマンドを実行して、マルチクラスターエンジン Operator の hypershift-addon を有効にします。

    clusteradm addon enable --names hypershift-addon --clusters <managed-cluster-names>
  4. Red Hat Advanced Cluster Management で次のコマンドを実行すると、マルチクラスターエンジン Operator が管理するクラスターの名前を取得できます。

    oc get managedcluster
  5. マルチクラスターエンジン Operator クラスターにログインし、指定した namespace に hypershift-addon がインストールされていることを確認します。以下のコマンドを実行します。

    oc get deployment -n open-cluster-management-agent-addon-discovery

    アドオンがリスト表示されている次の出力例を参照してください。

    NAME                                 READY   UP-TO-DATE   AVAILABLE   AGE
    cluster-proxy-proxy-agent            1/1     1            1           24h
    klusterlet-addon-workmgr            1/1     1            1           24h
    hypershift-addon-agent              1/1     1            1           24h
    managed-serviceaccount-addon-agent  1/1     1            1           24h

Red Hat Advanced Cluster Management が hypershift-addon をデプロイします。これは、マルチクラスターエンジン Operator からホステッドクラスターを検出する検出エージェントです。エージェントは、ホステッドクラスターの kube-apiserver が利用可能になると、Red Hat Advanced Cluster Management ハブクラスター内のマルチクラスターエンジン Operator が管理するクラスター namespace に、対応する DiscoveredCluster カスタムリソースを作成します。

検出されたクラスターはコンソールで表示できます。

  1. ハブクラスターコンソールにログインし、All Clusters > Infrastructure > Clusters に移動します。
  2. Discovered clusters タブを見つけて、タイプが MultiClusterEngineHCP のマルチクラスターエンジン Operator から検出されたすべてのホステッドクラスターを表示します。

次に、検出されたホステッドクラスターのインポートの自動化 を参照して、クラスターを自動的にインポートする方法を確認してください。

1.4.2. 検出されたホステッドクラスターのインポートの自動化

個々のクラスターを手動でインポートすることなく、DiscoveredCluster リソースを使用してホステッドクラスターのインポートを自動化し、クラスター管理を迅速化します。

検出されたホステッドクラスターを Red Hat Advanced Cluster Management に自動的にインポートすると、すべての Red Hat Advanced Cluster Management アドオンが有効になり、利用可能な管理ツールを使用してホステッドクラスターの管理を開始できるようになります。

ホステッドクラスターは、マルチクラスターエンジン Operator にも 自動的にインポート されます。マルチクラスターエンジン Operator のコンソールから、ホステッドクラスターのライフサイクルを管理できます。Red Hat Advanced Cluster Management のコンソールからは、ホステッドクラスターのライフサイクルを管理できません。

必要なアクセス権限: クラスターの管理者

1.4.2.1. 前提条件

  • Red Hat Advanced Cluster Management がインストールされている。Red Hat Advanced Cluster Management インストールおよびアップグレード に関するドキュメントを参照してください。
  • ポリシー を理解している。Red Hat Advanced Cluster Management ドキュメントの ガバナンス の概要を参照してください。

1.4.2.2. 自動インポートの設定

マネージドマルチクラスターエンジン Operator クラスターから検出されたホステッドクラスターは、Red Hat Advanced Cluster Management のマネージドマルチクラスターエンジン Operator クラスターの namespace にある DiscoveredCluster カスタムリソースで表されます。次の DiscoveredCluster リソースと namespace の例を参照してください。

apiVersion: discovery.open-cluster-management.io/v1
kind: DiscoveredCluster
metadata:
  creationTimestamp: "2024-05-30T23:05:39Z"
  generation: 1
  labels:
    hypershift.open-cluster-management.io/hc-name: hosted-cluster-1
    hypershift.open-cluster-management.io/hc-namespace: clusters
  name: hosted-cluster-1
  namespace: mce-1
  resourceVersion: "1740725"
  uid: b4c36dca-a0c4-49f9-9673-f561e601d837
spec:
  apiUrl: https://a43e6fe6dcef244f8b72c30426fb6ae3-ea3fec7b113c88da.elb.us-west-1.amazonaws.com:6443
  cloudProvider: aws
  creationTimestamp: "2024-05-30T23:02:45Z"
  credential: {}
  displayName: mce-1-hosted-cluster-1
  importAsManagedCluster: false
  isManagedCluster: false
  name: hosted-cluster-1
  openshiftVersion: 0.0.0
  status: Active
  type: MultiClusterEngineHCP

これらの検出されたホステッドクラスターは、spec.importAsManagedCluster フィールドが true に設定されるまで、Red Hat Advanced Cluster Management に自動的にインポートされません。Red Hat Advanced Cluster Management のポリシーを使用して、DiscoveredCluster リソース内のすべての type.MultiClusterEngineHCP でこのフィールドを自動的に true に設定し、検出されたホステッドクラスターがすぐに Red Hat Advanced Cluster Management に自動的にインポートされるようにする方法を説明します。

検出されたすべてのホステッドクラスターを自動的にインポートするようにポリシーを設定します。CLI からハブクラスターにログインして、次の手順を実行します。

  1. DiscoveredCluster カスタムリソースの YAML ファイルを作成し、次の例で後述する設定を編集します。

    apiVersion: policy.open-cluster-management.io/v1
    kind: Policy
    metadata:
      name: policy-mce-hcp-autoimport
      namespace: open-cluster-management-global-set
      annotations:
        policy.open-cluster-management.io/standards: NIST SP 800-53
        policy.open-cluster-management.io/categories: CM Configuration Management
        policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
        policy.open-cluster-management.io/description: Discovered clusters that are of
          type MultiClusterEngineHCP can be automatically imported into ACM as managed clusters.
          This policy configure those discovered clusters so they are automatically imported.
          Fine tuning MultiClusterEngineHCP clusters to be automatically imported
          can be done by configure filters at the configMap or add annotation to the discoverd cluster.
    spec:
      disabled: false
      policy-templates:
        - objectDefinition:
            apiVersion: policy.open-cluster-management.io/v1
            kind: ConfigurationPolicy
            metadata:
              name: mce-hcp-autoimport-config
            spec:
              object-templates:
                - complianceType: musthave
                  objectDefinition:
                    apiVersion: v1
                    kind: ConfigMap
                    metadata:
                      name: discovery-config
                      namespace: open-cluster-management-global-set
                    data:
                      rosa-filter: ""
              remediationAction: enforce 1
              severity: low
        - objectDefinition:
            apiVersion: policy.open-cluster-management.io/v1
            kind: ConfigurationPolicy
            metadata:
              name: policy-mce-hcp-autoimport
            spec:
              remediationAction: enforce
              severity: low
              object-templates-raw: |
                {{- /* find the MultiClusterEngineHCP DiscoveredClusters */ -}}
                {{- range $dc := (lookup "discovery.open-cluster-management.io/v1" "DiscoveredCluster" "" "").items }}
                  {{- /* Check for the flag that indicates the import should be skipped */ -}}
                  {{- $skip := "false" -}}
                  {{- range $key, $value := $dc.metadata.annotations }}
                    {{- if and (eq $key "discovery.open-cluster-management.io/previously-auto-imported")
                               (eq $value "true") }}
                      {{- $skip = "true" }}
                    {{- end }}
                  {{- end }}
                  {{- /* if the type is MultiClusterEngineHCP and the status is Active */ -}}
                  {{- if and (eq $dc.spec.status "Active")
                             (contains (fromConfigMap "open-cluster-management-global-set" "discovery-config" "mce-hcp-filter") $dc.spec.displayName)
                             (eq $dc.spec.type "MultiClusterEngineHCP")
                             (eq $skip "false") }}
                - complianceType: musthave
                  objectDefinition:
                    apiVersion: discovery.open-cluster-management.io/v1
                    kind: DiscoveredCluster
                    metadata:
                      name: {{ $dc.metadata.name }}
                      namespace: {{ $dc.metadata.namespace }}
                    spec:
                      importAsManagedCluster: true 2
                  {{- end }}
                {{- end }}
    1
    自動インポートを有効にするには、spec.remediationActionenforce に変更します。
    2
    自動インポートを有効にするには、spec.importAsManagedClustertrue に変更します。
  2. oc apply -f <filename>.yaml -n <namespace> を実行して、ファイルを適用します。

1.4.2.3. 配置定義の作成

ポリシーのデプロイ先のマネージドクラスターを指定する配置定義を作成する必要があります。次の手順を実行します。

  1. 管理対象のハブクラスターである local-cluster のみを選択する Placement 定義を作成します。以下の YAML 例を使用してください。

    apiVersion: cluster.open-cluster-management.io/v1beta1
    kind: Placement
    metadata:
      name: policy-mce-hcp-autoimport-placement
      namespace: open-cluster-management-global-set
    spec:
      tolerations:
        - key: cluster.open-cluster-management.io/unreachable
          operator: Exists
        - key: cluster.open-cluster-management.io/unavailable
          operator: Exists
      clusterSets:
        - global
      predicates:
        - requiredClusterSelector:
            labelSelector:
              matchExpressions:
                - key: local-cluster
                  operator: In
                  values:
                    - "true"
  2. oc apply -f placement.yaml -n <namespace> を実行します。namespace は、以前に作成したポリシーに使用した namespace と同じものです。

1.4.2.4. インポートポリシーを配置定義にバインドする

ポリシーと配置を作成したら、2 つのリソースを結び付ける必要があります。以下の手順を実行します。

  1. PlacementBinding リソースを使用してリソースを結び付けます。次の例を参照してください。placementRef は作成した Placement を参照し、subjects は作成した Policy を参照します。

    apiVersion: policy.open-cluster-management.io/v1
    kind: PlacementBinding
    metadata:
      name: policy-mce-hcp-autoimport-placement-binding
      namespace: open-cluster-management-global-set
    placementRef:
      name: policy-mce-hcp-autoimport-placement
      apiGroup: cluster.open-cluster-management.io
      kind: Placement
    subjects:
      - name: policy-mce-hcp-autoimport
        apiGroup: policy.open-cluster-management.io
        kind: Policy
  2. 検証するには、次のコマンドを実行します。

    oc get policy policy-mce-hcp-autoimport -n <namespace>

重要: Red Hat Advanced Cluster Management コンソールの Detach オプションを使用するか、コマンドラインから対応する ManagedCluster カスタムリソースを削除することにより、ホステッドクラスターを Red Hat Advanced Cluster Management から デタッチ できます。

最適な結果を得るには、ホステッドクラスターを 破棄 する前に、管理対象のホステッドクラスターをデタッチしてください。

検出されたクラスターがデタッチされると、検出されたクラスターが再度インポートされるのを防ぐために、次のアノテーションが DiscoveredCluster リソースに追加されます。

  annotations:
    discovery.open-cluster-management.io/previously-auto-imported: "true"

検出されたデタッチ済みクラスターを再インポートする場合は、このアノテーションを削除します。

1.4.3. 検出された OpenShift Service on AWS クラスターのインポートの自動化

個々のクラスターを手動でインポートすることなく、Red Hat Advanced Cluster Management のポリシー適用を使用して OpenShift Service on AWS クラスターのインポートを自動化し、クラスター管理を迅速化します。

必要なアクセス権限: クラスターの管理者

1.4.3.1. 前提条件

  • Red Hat Advanced Cluster Management がインストールされている。Red Hat Advanced Cluster Management インストールおよびアップグレード に関するドキュメントを参照してください。
  • ポリシー を理解している。Red Hat Advanced Cluster Management ドキュメントの ガバナンス の概要を参照してください。

1.4.3.2. 自動インポートポリシーの作成

次のポリシーと手順は、検出されたすべての OpenShift Service on AWS クラスターを自動的にインポートする方法の例です。

CLI からハブクラスターにログインして、次の手順を実行します。

  1. 次の例を使用して YAML ファイルを作成し、後述する変更を適用します。

    apiVersion: policy.open-cluster-management.io/v1
    kind: Policy
    metadata:
      name: policy-rosa-autoimport
      annotations:
        policy.open-cluster-management.io/standards: NIST SP 800-53
        policy.open-cluster-management.io/categories: CM Configuration Management
        policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
        policy.open-cluster-management.io/description: OpenShift Service on AWS discovered clusters can be automatically imported into
    Red Hat Advanced Cluster Management as managed clusters with this policy. You can select and configure those managed clusters so you can import. Configure filters or add an annotation if you do not want all of your OpenShift Service on AWS clusters to be automatically imported.
    spec:
      remediationAction: inform 1
      disabled: false
      policy-templates:
        - objectDefinition:
            apiVersion: policy.open-cluster-management.io/v1
            kind: ConfigurationPolicy
            metadata:
              name: rosa-autoimport-config
            spec:
              object-templates:
                - complianceType: musthave
                  objectDefinition:
                    apiVersion: v1
                    kind: ConfigMap
                    metadata:
                      name: discovery-config
                      namespace: open-cluster-management-global-set
                    data:
                      rosa-filter: "" 2
              remediationAction: enforce
              severity: low
        - objectDefinition:
            apiVersion: policy.open-cluster-management.io/v1
            kind: ConfigurationPolicy
            metadata:
              name: policy-rosa-autoimport
            spec:
              remediationAction: enforce
              severity: low
              object-templates-raw: |
                {{- /* find the ROSA DiscoveredClusters */ -}}
                {{- range $dc := (lookup "discovery.open-cluster-management.io/v1" "DiscoveredCluster" "" "").items }}
                  {{- /* Check for the flag that indicates the import should be skipped */ -}}
                  {{- $skip := "false" -}}
                  {{- range $key, $value := $dc.metadata.annotations }}
                    {{- if and (eq $key "discovery.open-cluster-management.io/previously-auto-imported")
                               (eq $value "true") }}
                      {{- $skip = "true" }}
                    {{- end }}
                  {{- end }}
                  {{- /* if the type is ROSA and the status is Active */ -}}
                  {{- if and (eq $dc.spec.status "Active")
                             (contains (fromConfigMap "open-cluster-management-global-set" "discovery-config" "rosa-filter") $dc.spec.displayName)
                             (eq $dc.spec.type "ROSA")
                             (eq $skip "false") }}
                - complianceType: musthave
                  objectDefinition:
                    apiVersion: discovery.open-cluster-management.io/v1
                    kind: DiscoveredCluster
                    metadata:
                      name: {{ $dc.metadata.name }}
                      namespace: {{ $dc.metadata.namespace }}
                    spec:
                      importAsManagedCluster: true
                  {{- end }}
                {{- end }}
        - objectDefinition:
            apiVersion: policy.open-cluster-management.io/v1
            kind: ConfigurationPolicy
            metadata:
              name: policy-rosa-managedcluster-status
            spec:
              remediationAction: enforce
              severity: low
              object-templates-raw: |
                {{- /* Use the same DiscoveredCluster list to check ManagedCluster status */ -}}
                {{- range $dc := (lookup "discovery.open-cluster-management.io/v1" "DiscoveredCluster" "" "").items }}
                  {{- /* Check for the flag that indicates the import should be skipped */ -}}
                  {{- $skip := "false" -}}
                  {{- range $key, $value := $dc.metadata.annotations }}
                    {{- if and (eq $key "discovery.open-cluster-management.io/previously-auto-imported")
                               (eq $value "true") }}
                      {{- $skip = "true" }}
                    {{- end }}
                  {{- end }}
                  {{- /* if the type is ROSA and the status is Active */ -}}
                  {{- if and (eq $dc.spec.status "Active")
                             (contains (fromConfigMap "open-cluster-management-global-set" "discovery-config" "rosa-filter") $dc.spec.displayName)
                             (eq $dc.spec.type "ROSA")
                             (eq $skip "false") }}
                - complianceType: musthave
                  objectDefinition:
                    apiVersion: cluster.open-cluster-management.io/v1
                    kind: ManagedCluster
                    metadata:
                      name: {{ $dc.spec.displayName }}
                      namespace: {{ $dc.spec.displayName }}
                    status:
                      conditions:
                        - type: ManagedClusterConditionAvailable
                          status: "True"
                  {{- end }}
                {{- end }}
    1
    自動インポートを有効にするには、spec.remediationActionenforce に変更します。
    2
    オプション: 検出された クラスター名に基づいて、一致する OpenShift Service on AWS クラスターのサブセットを選択するには、ここで値を指定します。rosa-filter にはデフォルトで値がないため、このフィルターによってサブセット値のないクラスター名が制限されることはありません。
  2. oc apply -f <filename>.yaml -n <namespace> を実行して、ファイルを適用します。

1.4.3.3. 配置定義の作成

ポリシーのデプロイ先のマネージドクラスターを指定する配置定義を作成する必要があります。

  1. 管理対象のハブクラスターである local-cluster のみを選択する配置定義を作成します。以下の YAML 例を使用してください。

    apiVersion: cluster.open-cluster-management.io/v1beta1
    kind: Placement
    metadata:
      name: placement-openshift-plus-hub
    spec:
      predicates:
      - requiredClusterSelector:
          labelSelector:
            matchExpressions:
            - key: name
          	    operator: In
          	    values:
          	    - local-cluster
  2. oc apply -f placement.yaml -n <namespace> を実行します。namespace は、以前に作成したポリシーに使用した namespace と同じものです。

1.4.3.4. インポートポリシーを配置定義にバインドする

ポリシーと配置を作成したら、2 つのリソースを結び付ける必要があります。

  1. PlacementBinding を使用してリソースを結び付けます。次の例を参照してください。placementRef は作成した Placement を参照し、subjects は作成した Policy を参照します。

    apiVersion: policy.open-cluster-management.io/v1
    kind: PlacementBinding
    metadata:
      name: binding-policy-rosa-autoimport
    placementRef:
      apiGroup: cluster.open-cluster-management.io
      kind: Placement
      name: placement-policy-rosa-autoimport
    subjects:
    - apiGroup: policy.open-cluster-management.io
      kind: Policy
      name: policy-rosa-autoimport
  2. 検証するには、次のコマンドを実行します。

    oc get policy policy-rosa-autoimport -n <namespace>

1.4.4. 可観測性の統合

Red Hat Advanced Cluster Management の可観測性機能を使用すると、クラスター全体の健全性と使用状況を表示できます。Red Hat Advanced Cluster Management をインストールして可観測性機能を有効にできます。

1.4.4.1. Hosted Control Plane の観測

multicluster-observability Pod を有効にすると、Red Hat Advanced Cluster Management Observability Grafana ダッシュボードを使用して、Hosted Control Plane に関する次の情報を表示できます。

  • ACM > Hosted Control Planes Overview で、Hosted Control Plane をホストするためのクラスター容量の推定値、関連するクラスターリソース、および既存の Hosted Control Plane のリストとステータスを確認できます。
  • ACM > Resources > Hosted Control Plane ダッシュボード (Overview ページからアクセス可能) で、選択した Hosted Control Plane のリソース使用率を確認できます。

有効にするには、Observability サービス を参照してください。

Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

© 2024 Red Hat, Inc.