4.3. cluster-compare プラグインの使用


cluster-compare プラグインを使用すると、参照設定をライブクラスターまたは must-gather データからの設定と比較できます。

4.3.1. ライブクラスターでの cluster-compare プラグインの使用

cluster-compare プラグインを使用すると、参照設定をライブクラスターの設定カスタムリソース (CR) と比較できます。

設計中、開発中、またはテスト中に、ライブクラスターの設定を検証し、参照設定に準拠していることを確認してください。

注記

cluster-compare プラグインは、非実稼働環境のライブクラスターでのみ使用してください。実稼働環境の場合は、must-gather データに対してプラグインを使用してください。

前提条件

  • OpenShift CLI (oc) がインストールされている。
  • cluster-admin ロールを持つユーザーとしてクラスターにアクセスできる。
  • cluster-compare プラグインをダウンロードし、PATH 環境変数に含めた。
  • 参照設定にアクセスできる。

手順

  • 次のコマンドを使用して、cluster-compare プラグインを実行します。

    $ oc cluster-compare -r <path_to_reference_config>/metadata.yaml
    • -r は、参照設定の metadata.yaml ファイルへのパスを指定します。ローカルディレクトリーまたは URI を指定できます。

      出力例

      ...
      
      **********************************
      
      Cluster CR: operator.openshift.io/v1_Console_cluster 1
      Reference File: optional/console-disable/ConsoleOperatorDisable.yaml 2
      Diff Output: diff -u -N /tmp/MERGED-622469311/operator-openshift-io-v1_console_cluster /tmp/LIVE-2358803347/operator-openshift-io-v1_console_cluster
      /tmp/MERGED-622469311/operator-openshift-io-v1_console_cluster	2024-11-20 15:43:42.888633602 +0000
      +++ /tmp/LIVE-2358803347/operator-openshift-io-v1_console_cluster	2024-11-20 15:43:42.888633602 +0000
      @@ -4,5 +4,5 @@
         name: cluster
       spec:
         logLevel: Normal
      -  managementState: Removed 3
      +  managementState: Managed
         operatorLogLevel: Normal
      
      **********************************
      
      …
      
      Summary 4
      CRs with diffs: 5/49 5
      CRs in reference missing from the cluster: 1 6
      required-cluster-tuning:
        cluster-tuning:
          Missing CRs: 7
          - required/cluster-tuning/disabling-network-diagnostics/DisableSnoNetworkDiag.yaml
      No CRs are unmatched to reference CRs 8
      Metadata Hash: 512a9bf2e57fd5a5c44bbdea7abb3ffd7739d4a1f14ef9021f6793d5cdf868f0 9
      No patched CRs 10

      1
      比較対象の CR。プラグインにより、対応するテンプレートとの差異のある各 CR が表示されます。
      2
      比較対象の CR とマッチするテンプレート。
      3
      Linux diff 形式の出力に、テンプレートとクラスター CR の差異が表示されます。
      4
      プラグインにより、各 CR の行の差分が報告されます。その後、差分の概要が報告されます。
      5
      対応するテンプレートとの差異を比較した CR の数。
      6
      参照設定に表されているが、ライブクラスターには存在しない CR の数。
      7
      参照設定に表されているが、ライブクラスターには存在しない CR のリスト。
      8
      参照設定内の対応するテンプレートとマッチしなかった CR。
      9
      メタデータハッシュは参照設定を識別するものです。
      10
      パッチが適用された CR のリスト。

4.3.2. must-gather データでの cluster-compare プラグインの使用

cluster-compare プラグインを使用すると、参照設定を must-gather データからの設定カスタムリソース (CR) と比較できます。

must-gather データを使用してクラスター設定を検証し、実稼働環境での設定の問題をトラブルシューティングします。

注記

実稼働環境の場合は、必ず must-gather データに対して cluster-compare プラグインを使用してください。

  • ターゲットクラスターから must-gather データにアクセスできる。
  • OpenShift CLI (oc) がインストールされている。
  • cluster-compare プラグインをダウンロードし、PATH 環境変数に含めた。
  • 参照設定にアクセスできる。

手順

  • 次のコマンドを実行して、must-gather データを参照設定と比較します。

    $ oc cluster-compare -r <path_to_reference_config>/metadata.yaml -f "must-gather*/*/cluster-scoped-resources","must-gather*/*/namespaces" -R
    • -r は、参照設定の metadata.yaml ファイルへのパスを指定します。ローカルディレクトリーまたは URI を指定できます。
    • -f は、must-gather データディレクトリーへのパスを指定します。ローカルディレクトリーまたは URI を指定できます。この例では、比較対象を重要なクラスター設定ディレクトリーに制限します。
    • -R は、ターゲットディレクトリーを再帰的に検索します。

      出力例

      ...
      
      **********************************
      
      Cluster CR: operator.openshift.io/v1_Console_cluster 1
      Reference File: optional/console-disable/ConsoleOperatorDisable.yaml 2
      Diff Output: diff -u -N /tmp/MERGED-622469311/operator-openshift-io-v1_console_cluster /tmp/LIVE-2358803347/operator-openshift-io-v1_console_cluster
      /tmp/MERGED-622469311/operator-openshift-io-v1_console_cluster	2024-11-20 15:43:42.888633602 +0000
      +++ /tmp/LIVE-2358803347/operator-openshift-io-v1_console_cluster	2024-11-20 15:43:42.888633602 +0000
      @@ -4,5 +4,5 @@
         name: cluster
       spec:
         logLevel: Normal
      -  managementState: Removed 3
      +  managementState: Managed
         operatorLogLevel: Normal
      
      **********************************
      
      …
      
      Summary 4
      CRs with diffs: 5/49 5
      CRs in reference missing from the cluster: 1 6
      required-cluster-tuning:
        cluster-tuning:
          Missing CRs: 7
          - required/cluster-tuning/disabling-network-diagnostics/DisableSnoNetworkDiag.yaml
      No CRs are unmatched to reference CRs 8
      Metadata Hash: 512a9bf2e57fd5a5c44bbdea7abb3ffd7739d4a1f14ef9021f6793d5cdf868f0 9
      No patched CRs 10

      1
      比較対象の CR。プラグインにより、対応するテンプレートとの差異のある各 CR が表示されます。
      2
      比較対象の CR とマッチするテンプレート。
      3
      Linux diff 形式の出力に、テンプレートとクラスター CR の差異が表示されます。
      4
      プラグインにより、各 CR の行の差分が報告されます。その後、差分の概要が報告されます。
      5
      対応するテンプレートとの差異を比較した CR の数。
      6
      参照設定に表されているが、ライブクラスターには存在しない CR の数。
      7
      参照設定に表されているが、ライブクラスターには存在しない CR のリスト。
      8
      参照設定内の対応するテンプレートとマッチしなかった CR。
      9
      メタデータハッシュは参照設定を識別するものです。
      10
      パッチが適用された CR のリスト。

4.3.3. cluster-compare プラグインのオプションのリファレンス

ここでは、cluster-compare プラグインのオプションについて説明します。

表4.1 cluster-compare プラグインのオプション
オプション説明

-A--all-resources

ライブクラスターで使用すると、参照設定内のタイプに一致するクラスター内の全リソースとのマッチングを試行します。ローカルファイルで使用すると、参照設定内のタイプに一致するローカルファイル内の全リソースとのマッチングを試行します。

--concurrency

ライブバージョンのリソースと比較するときに、並列処理するテンプレートの数の整数値を指定します。数値が大きいほど速度は増加しますが、その期間中のメモリー、I/O、CPU の使用率も増加します。デフォルト値は 4 です。

-c--diff-config

ユーザー設定ファイルへのパスを指定します。

-f--filename

参照設定との比較に使用する設定カスタムリソースのファイル名、ディレクトリー、または URL を指定します。

--generate-override-for

パッチが必要なテンプレートのパスを指定します。

注記

metadata.yaml ファイルを基準とした対象テンプレートのファイルパスを使用する必要があります。たとえば、metadata.yaml ファイルのファイルパスが ./compare/metadata.yaml の場合、テンプレートの相対ファイルパスは optional/my-template.yaml です。

-h--help

ヘルプ情報を表示します。

-k--kustomize

kustomization ディレクトリーを処理するためのパスを指定します。このフラグは -f または -R と一緒に使用することはできません。

-o--output

出力形式を指定します。jsonyamlgenerate-patches を指定できます。

--override-reason

オーバーライドを生成する理由を指定します。

-p--overrides

参照設定のパッチオーバーライドファイルへのパスを指定します。

-R--recursive

-f--filename で指定されたディレクトリーを再帰的に処理します。

-r--reference

参照設定の metadata.yaml ファイルへのパスを指定します。

--show-managed-fields

マネージドフィールドを比較に含めるには true を指定します。

-v--verbose

プラグイン出力の詳細度を高めます。

4.3.4. 例: クラスターと通信事業者向けコア参照設定の比較

4.3.5. クラスターと通信事業者向けコア参照設定の比較

通信事業者向けコアクラスターをデプロイした後、cluster-compare プラグインを使用して、クラスターが通信事業者向けコアリファレンス設計仕様 (RDS) に準拠しているかどうかを評価できます。cluster-compare プラグインは、OpenShift CLI (oc) のプラグインです。このプラグインは、通信事業者向けコア参照設定を使用して、通信事業者向けコアカスタムリソース (CR) を使用するクラスターを検証します。

プラグイン固有の通信事業者向けコア参照設定は、通信事業者向けコア CR とともにコンテナーイメージにパッケージ化されています。

cluster-compare プラグインの詳細は、「cluster-compare プラグインについて」を参照してください。

cluster-compare プラグインを使用すると、参照設定をライブクラスターまたは must-gather データからの設定と比較できます。

この例では、ライブクラスターの設定と通信事業者向けコア参照設定を比較します。通信事業者向けコア参照設定は、通信事業者向けコアリファレンス設計仕様 (RDS) に基づくものです。通信事業者向けコア RDS は、コントロールプレーンや一部の集中型データプレーン機能を含む大規模な通信アプリケーションを支えるクラスター向けに設計されています。

参照設定は、通信事業者向け Core RDS とともにコンテナーイメージにパッケージ化されています。

cluster-compare プラグインを通信事業者向けコアプロファイルおよび通信事業者向け RAN 分散ユニット (DU) プロファイルとともに使用する例については、「関連情報」セクションを参照してください。

前提条件

  • cluster-admin ロールを持つユーザーとしてクラスターにアクセスできる。
  • registry.redhat.io コンテナーイメージレジストリーにアクセスするための認証情報がある。
  • cluster-compare プラグインをインストールした。

手順

  1. 次のコマンドを実行して、認証情報を使用してコンテナーイメージレジストリーにログインします。

    $ podman login registry.redhat.io
  2. 次のコマンドを実行して、telco-core-rds-rhel9 コンテナーイメージからコンテンツを抽出します。

    $ mkdir -p ./out
    $ podman run -it registry.redhat.io/openshift4/openshift-telco-core-rds-rhel9:v4.18 | base64 -d | tar xv -C out

    参照設定は、reference-crs-kube-compare/ ディレクトリーで確認できます。

    out/telco-core-rds/configuration/reference-crs-kube-compare/
    ├── metadata.yaml 1
    ├── optional 2
    │   ├── logging
    │   ├── networking
    │   ├── other
    │   └── tuning
    └── required 3
        ├── networking
        ├── other
        ├── performance
        ├── scheduling
        └── storage
    1
    参照設定用の設定ファイル。
    2
    任意のテンプレート用のディレクトリー。
    3
    必須のテンプレート用のディレクトリー。
  3. 次のコマンドを実行して、クラスターの設定を通信事業者向けコア参照設定と比較します。

    $ oc cluster-compare -r out/telco-core-rds/configuration/reference-crs-kube-compare/metadata.yaml

    出力例

    W1212 14:13:06.281590   36629 compare.go:425] Reference Contains Templates With Types (kind) Not Supported By Cluster: BFDProfile, BGPAdvertisement, BGPPeer, ClusterLogForwarder, Community, IPAddressPool, MetalLB, MultiNetworkPolicy, NMState, NUMAResourcesOperator, NUMAResourcesScheduler, NodeNetworkConfigurationPolicy, SriovNetwork, SriovNetworkNodePolicy, SriovOperatorConfig, StorageCluster
    
    ...
    
    **********************************
    
    Cluster CR: config.openshift.io/v1_OperatorHub_cluster 1
    Reference File: required/other/operator-hub.yaml 2
    Diff Output: diff -u -N /tmp/MERGED-2801470219/config-openshift-io-v1_operatorhub_cluster /tmp/LIVE-2569768241/config-openshift-io-v1_operatorhub_cluster
    --- /tmp/MERGED-2801470219/config-openshift-io-v1_operatorhub_cluster	2024-12-12 14:13:22.898756462 +0000
    +++ /tmp/LIVE-2569768241/config-openshift-io-v1_operatorhub_cluster	2024-12-12 14:13:22.898756462 +0000
    @@ -1,6 +1,6 @@
     apiVersion: config.openshift.io/v1
     kind: OperatorHub
     metadata:
    +  annotations: 3
    +    include.release.openshift.io/hypershift: "true"
       name: cluster
    -spec:
    -  disableAllDefaultSources: true
    
    **********************************
    
    Summary 4
    CRs with diffs: 3/4 5
    CRs in reference missing from the cluster: 22 6
    other:
      other:
        Missing CRs: 7
        - optional/other/control-plane-load-kernel-modules.yaml
        - optional/other/worker-load-kernel-modules.yaml
    required-networking:
      networking-root:
        Missing CRs:
        - required/networking/nodeNetworkConfigurationPolicy.yaml
      networking-sriov:
        Missing CRs:
        - required/networking/sriov/sriovNetwork.yaml
        - required/networking/sriov/sriovNetworkNodePolicy.yaml
        - required/networking/sriov/SriovOperatorConfig.yaml
        - required/networking/sriov/SriovSubscription.yaml
        - required/networking/sriov/SriovSubscriptionNS.yaml
        - required/networking/sriov/SriovSubscriptionOperGroup.yaml
    required-other:
      scheduling:
        Missing CRs:
        - required/other/catalog-source.yaml
        - required/other/icsp.yaml
    required-performance:
      performance:
        Missing CRs:
        - required/performance/PerformanceProfile.yaml
    required-scheduling:
      scheduling:
        Missing CRs:
        - required/scheduling/nrop.yaml
        - required/scheduling/NROPSubscription.yaml
        - required/scheduling/NROPSubscriptionNS.yaml
        - required/scheduling/NROPSubscriptionOperGroup.yaml
        - required/scheduling/sched.yaml
    required-storage:
      storage-odf:
        Missing CRs:
        - required/storage/odf-external/01-rook-ceph-external-cluster-details.secret.yaml
        - required/storage/odf-external/02-ocs-external-storagecluster.yaml
        - required/storage/odf-external/odfNS.yaml
        - required/storage/odf-external/odfOperGroup.yaml
        - required/storage/odf-external/odfSubscription.yaml
    No CRs are unmatched to reference CRs 8
    Metadata Hash: fe41066bac56517be02053d436c815661c9fa35eec5922af25a1be359818f297 9
    No patched CRs 10

    1
    比較対象の CR。プラグインにより、対応するテンプレートとの差異のある各 CR が表示されます。
    2
    比較対象の CR とマッチするテンプレート。
    3
    Linux diff 形式の出力に、テンプレートとクラスター CR の差異が表示されます。
    4
    プラグインにより、各 CR の行の差分が報告されます。その後、差分の概要が報告されます。
    5
    対応するテンプレートとの差異を比較した CR の数。
    6
    参照設定に表されているが、ライブクラスターには存在しない CR の数。
    7
    参照設定に表されているが、ライブクラスターには存在しない CR のリスト。
    8
    参照設定内の対応するテンプレートとマッチしなかった CR。
    9
    メタデータハッシュは参照設定を識別するものです。
    10
    パッチが適用された CR のリスト。
  4. 次のコマンドを実行して、ztp-site-generate-rhel8 コンテナーイメージからコンテンツを抽出します。

    $ podman pull registry.redhat.io/openshift4/ztp-site-generate-rhel8:v4.18
    $ mkdir -p ./out
    $ podman run --log-driver=none --rm registry.redhat.io/openshift4/ztp-site-generate-rhel8:v4.18 extract /home/ztp --tar | tar x -C ./out
  5. 次のコマンドを実行して、クラスターの設定を参照設定と比較します。

    $ oc cluster-compare -r out/reference/metadata.yaml

    出力例

    ...
    
    **********************************
    
    Cluster CR: config.openshift.io/v1_OperatorHub_cluster 1
    Reference File: required/other/operator-hub.yaml 2
    Diff Output: diff -u -N /tmp/MERGED-2801470219/config-openshift-io-v1_operatorhub_cluster /tmp/LIVE-2569768241/config-openshift-io-v1_operatorhub_cluster
    --- /tmp/MERGED-2801470219/config-openshift-io-v1_operatorhub_cluster	2024-12-12 14:13:22.898756462 +0000
    +++ /tmp/LIVE-2569768241/config-openshift-io-v1_operatorhub_cluster	2024-12-12 14:13:22.898756462 +0000
    @@ -1,6 +1,6 @@
     apiVersion: config.openshift.io/v1
     kind: OperatorHub
     metadata:
    +  annotations: 3
    +    include.release.openshift.io/hypershift: "true"
       name: cluster
    -spec:
    -  disableAllDefaultSources: true
    
    **********************************
    
    Summary 4
    CRs with diffs: 11/12 5
    CRs in reference missing from the cluster: 40 6
    optional-image-registry:
      image-registry:
        Missing CRs: 7
        - optional/image-registry/ImageRegistryPV.yaml
    optional-ptp-config:
      ptp-config:
        One of the following is required:
        - optional/ptp-config/PtpConfigBoundary.yaml
        - optional/ptp-config/PtpConfigGmWpc.yaml
        - optional/ptp-config/PtpConfigDualCardGmWpc.yaml
        - optional/ptp-config/PtpConfigForHA.yaml
        - optional/ptp-config/PtpConfigMaster.yaml
        - optional/ptp-config/PtpConfigSlave.yaml
        - optional/ptp-config/PtpConfigSlaveForEvent.yaml
        - optional/ptp-config/PtpConfigForHAForEvent.yaml
        - optional/ptp-config/PtpConfigMasterForEvent.yaml
        - optional/ptp-config/PtpConfigBoundaryForEvent.yaml
      ptp-operator-config:
        One of the following is required:
        - optional/ptp-config/PtpOperatorConfig.yaml
        - optional/ptp-config/PtpOperatorConfigForEvent.yaml
    optional-storage:
      storage:
        Missing CRs:
        - optional/local-storage-operator/StorageLV.yaml
    
    ...
    
    No CRs are unmatched to reference CRs 8
    Metadata Hash: 09650c31212be9a44b99315ec14d2e7715ee194a5d68fb6d24f65fd5ddbe3c3c 9
    No patched CRs 10

    1
    比較対象の CR。プラグインにより、対応するテンプレートとの差異のある各 CR が表示されます。
    2
    比較対象の CR とマッチするテンプレート。
    3
    Linux diff 形式の出力に、テンプレートとクラスター CR の差異が表示されます。
    4
    プラグインにより、各 CR の行の差分が報告されます。その後、差分の概要が報告されます。
    5
    対応するテンプレートとの差異を比較した CR の数。
    6
    参照設定に表されているが、ライブクラスターには存在しない CR の数。
    7
    参照設定に表されているが、ライブクラスターには存在しない CR のリスト。
    8
    参照設定内の対応するテンプレートとマッチしなかった CR。
    9
    メタデータハッシュは参照設定を識別するものです。
    10
    パッチが適用された CR のリスト。

4.3.6. 関連情報

Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

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

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

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

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

会社概要

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

© 2024 Red Hat, Inc.