2.17.8. ユーザーのワークロード監視との統合


デフォルトでは、Red Hat OpenShift Service Mesh (OSSM) は、メッシュからメトリクスを収集するための Prometheus の専用インスタンスを含む Service Mesh コントロールプレーン (SMCP) をインストールします。ただし、実稼働システムには、ユーザー定義プロジェクトの OpenShift Container Platform モニタリングなど、より高度なモニタリングシステムが必要です。

次の手順では、Service Mesh をユーザーワークロードの監視と統合する方法を示します。

前提条件

  • ユーザーのワークロードの監視が有効になっている。
  • Red Hat OpenShift Service Mesh Operator 2.4 がインストールされている。
  • Kiali Operator 1.65 がインストールされている。

手順

  1. cluster-monitoring-view ロールを Kiali サービスアカウントに付与します。

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: kiali-monitoring-rbac
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: cluster-monitoring-view
    subjects:
    - kind: ServiceAccount
      name: kiali-service-account
      namespace: istio-system
  2. ユーザーワークロードを監視するために Kiali を設定します。

    apiVersion: kiali.io/v1alpha1
    kind: Kiali
    metadata:
      name: kiali-user-workload-monitoring
      namespace: istio-system
    spec:
      external_services:
        prometheus:
          auth:
            type: bearer
            use_kiali_token: true
          query_scope:
            mesh_id: "basic-istio-system"
          thanos_proxy:
            enabled: true
          url: https://thanos-querier.openshift-monitoring.svc.cluster.local:9091
    • Istio Operator 2.4 を使用する場合は、次の設定を使用して Kiali をユーザーワークロードモニタリング用に設定します。

      apiVersion: kiali.io/v1alpha1
      kind: Kiali
      metadata:
        name: kiali-user-workload-monitoring
        namespace: istio-system
      spec:
        external_services:
          istio:
            config_map_name: istio-<smcp-name>
            istio_sidecar_injector_config_map_name: istio-sidecar-injector-<smcp-name>
            istiod_deployment_name: istiod-<smcp-name>
            url_service_version: 'http://istiod-<smcp-name>.istio-system:15014/version'
          prometheus:
            auth:
              token: secret:thanos-querier-web-token:token
              type: bearer
              use_kiali_token: false
            query_scope:
              mesh_id: "basic-istio-system"
            thanos_proxy:
              enabled: true
            url: https://thanos-querier.openshift-monitoring.svc.cluster.local:9091
        version: v1.65
  3. 外部 Prometheus 用に SMCP を設定します。

    apiVersion: maistra.io/v2
    kind: ServiceMeshControlPlane
    metadata:
      name: basic
      namespace: istio-system
    spec:
      addons:
        prometheus:
          enabled: false 
    1
    
        grafana:
          enabled: false 
    2
    
        kiali:
          name: kiali-user-workload-monitoring
      meshConfig:
        extensionProviders:
        - name: prometheus
          prometheus: {}
    1
    OSSM によって提供されるデフォルトの Prometheus インスタンスを無効にします。
    2
    Grafana を無効にします。外部 Prometheus インスタンスではサポートされていません。
  4. カスタムネットワークポリシーを適用して、モニタリング namespace からの受信トラフィックを許可します。

    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: user-workload-access
      namespace: istio-system 
    1
    
    spec:
      ingress:
      - from:
        - namespaceSelector:
            matchLabels:
              network.openshift.io/policy-group: monitoring
      podSelector: {}
      policyTypes:
      - Ingress
    1
    カスタムネットワークポリシーはすべての namespace に適用する必要があります。
  5. Telemetry オブジェクトを適用して、Istio プロキシーのトラフィックメトリクスを有効にします。

    apiVersion: telemetry.istio.io/v1alpha1
    kind: Telemetry
    metadata:
      name: enable-prometheus-metrics
      namespace: istio-system 
    1
    
    spec:
      selector: 
    2
    
        matchLabels:
          app: bookinfo
      metrics:
      - providers:
        - name: prometheus
    1
    コントロールプレーンの namespace で作成された Telemetry オブジェクトは、メッシュ内のすべてのワークロードに適用されます。Telemetry を 1 つの namespace のみに適用するには、ターゲット namespace にオブジェクトを作成します。
    2
    オプション: selector.matchLabels 仕様を設定すると、ターゲット namespace 内の特定のワークロードに Telemetry オブジェクトが適用されます。
  6. ServiceMonitor オブジェクトを適用して Istio コントロールプレーンを監視します。

    apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
      name: istiod-monitor
      namespace: istio-system 
    1
    
    spec:
      targetLabels:
      - app
      selector:
        matchLabels:
          istio: pilot
      endpoints:
      - port: http-monitoring
        interval: 30s
        relabelings:
        - action: replace
          replacement: "basic-istio-system" 
    2
    
          targetLabel: mesh_id
    1
    この ServiceMonitor オブジェクトは Istiod サービスを監視するため、Istio コントロールプレーン namespace に作成します。この例では、namespace は istio-system です。
    2
    文字列 "basic-istio-system" は、SMCP 名とその namespace の組み合わせですが、クラスター内のユーザーワークロード監視を使用するメッシュごとに一意である限り、任意のラベルを使用できます。ステップ 2 で設定した Kiali リソースの spec.prometheus.query_scope は、この値と一致する必要があります。
    注記

    ユーザーワークロードモニタリングを使用しているメッシュが 1 つだけの場合は、Kiali リソースの mesh_id の再ラベル付けと spec.prometheus.query_scope フィールドは、両方とも任意です (ただし、mesh_id ラベルが削除された場合は、ここで指定した query_scope フィールドも削除する必要があります)。

    クラスター上の複数のメッシュインスタンスがユーザーワークロードのモニタリングを使用する可能性がある場合は、Kiali リソースの mesh_id の再ラベル付けと spec.prometheus.query_scope フィールドの両方が必要です。これにより、Kiali は関連付けられたメッシュからのメトリクスのみ参照します。

    Kiali をデプロイしていない場合でも、別のメッシュのメトリクスを区別できるように mesh_id の再ラベル付けを適用できます。

  7. PodMonitor オブジェクトを適用して、Istio プロキシーからメトリクスを収集します。

    apiVersion: monitoring.coreos.com/v1
    kind: PodMonitor
    metadata:
      name: istio-proxies-monitor
      namespace: istio-system 
    1
    
    spec:
      selector:
        matchExpressions:
        - key: istio-prometheus-ignore
          operator: DoesNotExist
      podMetricsEndpoints:
      - path: /stats/prometheus
        interval: 30s
        relabelings:
        - action: keep
          sourceLabels: [__meta_kubernetes_pod_container_name]
          regex: "istio-proxy"
        - action: keep
          sourceLabels: [__meta_kubernetes_pod_annotationpresent_prometheus_io_scrape]
        - action: replace
          regex: (\d+);(([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4})
          replacement: '[$2]:$1'
          sourceLabels: [__meta_kubernetes_pod_annotation_prometheus_io_port,
          __meta_kubernetes_pod_ip]
          targetLabel: __address__
        - action: replace
          regex: (\d+);((([0-9]+?)(\.|$)){4})
          replacement: $2:$1
          sourceLabels: [__meta_kubernetes_pod_annotation_prometheus_io_port,
          __meta_kubernetes_pod_ip]
          targetLabel: __address__
        - action: labeldrop
          regex: "__meta_kubernetes_pod_label_(.+)"
        - sourceLabels: [__meta_kubernetes_namespace]
          action: replace
          targetLabel: namespace
        - sourceLabels: [__meta_kubernetes_pod_name]
          action: replace
          targetLabel: pod_name
        - action: replace
          replacement: "basic-istio-system" 
    2
    
          targetLabel: mesh_id
    1
    OpenShift Container Platform モニタリングは ServiceMonitor オブジェクトと PodMonitor オブジェクトの namespaceSelector 仕様を無視するため、コントロールプレーンの namespace を含むすべてのメッシュ namespace に PodMonitor オブジェクトを適用する必要があります。
    2
    文字列 "basic-istio-system" は、SMCP 名とその namespace の組み合わせですが、クラスター内のユーザーワークロード監視を使用するメッシュごとに一意である限り、任意のラベルを使用できます。ステップ 2 で設定した Kiali リソースの spec.prometheus.query_scope は、この値と一致する必要があります。
    注記

    ユーザーワークロードモニタリングを使用しているメッシュが 1 つだけの場合は、Kiali リソースの mesh_id の再ラベル付けと spec.prometheus.query_scope フィールドは、両方とも任意です (ただし、mesh_id ラベルが削除された場合は、ここで指定した query_scope フィールドも削除する必要があります)。

    クラスター上の複数のメッシュインスタンスがユーザーワークロードのモニタリングを使用する可能性がある場合は、Kiali リソースの mesh_id の再ラベル付けと spec.prometheus.query_scope フィールドの両方が必要です。これにより、Kiali は関連付けられたメッシュからのメトリクスのみ参照します。

    Kiali をデプロイしていない場合でも、別のメッシュのメトリクスを区別できるように mesh_id の再ラベル付けを適用できます。

  8. OpenShift Container Platform Web コンソールを開き、メトリクスが表示されていることを確認します。
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

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

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

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

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

Legal Notice

Theme

© 2026 Red Hat
トップに戻る