検索

2.4. NotificationsConfiguration カスタムリソースプロパティー

download PDF

NotificationsConfiguration リソースは、Kubernetes クラスター内の通知を管理する Kubernetes カスタムリソース (CR) です。Red Hat OpenShift GitOps では、NotificationsConfiguration CR を使用して、テンプレート、トリガー、サービス、サブスクリプションリソースを Argo CD Notifications config map に追加できます。

通知を有効にして Red Hat OpenShift GitOps でクラスターを作成すると、デフォルトで default-notifications-configuration という名前の NotificationsConfiguration CR が作成されます。

NotificationsConfiguration CR の既存の設定に加えられた変更は、Argo CD Notifications config map に複製されます。たとえば、ユーザーが NotificationsConfiguration リソースにトリガー設定を追加すると、この設定は Argo CD Notifications config map 内で読み取られ、処理され、更新されます。

重要

設定の変更はすべて、default-notifications-configuration CR で更新する必要があります。NotificationsConfiguration リソース用にユーザーが作成したカスタムリソースはサポートされていません。

Argo CD argocd-notifications-cm config map への変更は、NotificationsConfiguration CR で行われた変更によって上書きされます。

表2.1 NotificationsConfiguration カスタムリソースプロパティー
プロパティーDefault説明

テンプレート

<empty>

テンプレートは、通知テンプレートメッセージを生成するために使用されます。

Triggers

<empty>

トリガーは、ユーザーに通知が送信される条件と、メッセージを生成するために必要なテンプレートのリストを定義するために使用されます。

サービス

<empty>

サービスはメッセージを配信するために使用されます。

サブスクリプション

<empty>

サブスクリプションには、集中管理されたグローバルアプリケーションサブスクリプションが含まれます。

次の例では、default-notifications-configuration カスタムリソースを使用して、テンプレート、トリガー、サービス、およびサブスクリプションリソースを Argo CD argocd-notification-cm config map に追加する方法を定義します。

templates の例

apiVersion: argoproj.io/v1alpha1
kind: NotificationsConfiguration
metadata:
 name: default-notifications-configuration 1
spec:
 templates:
  template.my-custom-template: | 2
    message: |
     Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}.

1
クラスター内の NotificationsConfiguration CR のデフォルト名。
2
NotificationsConfiguration CR のカスタムテンプレート設定の例。

triggers の例

apiVersion: argoproj.io/v1alpha1
kind: NotificationsConfiguration
metadata:
 name: default-notifications-configuration 1
spec:
 triggers:
  trigger.on-sync-status-unknown: | 2
   - when: app.status.sync.status == 'Unknown'
   send: [my-custom-template]

1
クラスター内の NotificationsConfiguration CR のデフォルト名。
2
NotificationsConfiguration CR のカスタムトリガー設定の例。

services の例

apiVersion: argoproj.io/v1alpha1
kind: NotificationsConfiguration
metadata:
 name: default-notifications-configuration 1
spec:
 Services:
  service.slack: |
    token: $slack-token 2
    username: <override-username> # optional username
    icon: <override-icon> # optional icon for the message (supports both emoji and url notation)

1
クラスター内の NotificationsConfiguration CR のデフォルト名。
2
NotificationsConfiguration CR のカスタムサービス設定の例。

subscriptions の例

apiVersion: argoproj.io/v1alpha1
kind: NotificationsConfiguration
metadata:
 name: default-notifications-configuration 1
spec:
 Subscriptions: |
  subscriptions: | 2
    # subscription for on-sync-status-unknown trigger notifications
    - recipients:
    - slack:test2
    - email:test@gmail.com
    triggers:
    - on-sync-status-unknown
    # subscription restricted to applications with matching labels only
    - recipients:
    - slack:test3
    selector: test=true
    triggers:
    - on-sync-status-unknown
icon: <override-icon> # optional icon for the message (supports both emoji and url notation)

1
クラスター内の NotificationsConfiguration CR のデフォルト名。
2
NotificationsConfiguration CR のカスタムサブスクリプション設定の例。

OpenShift Container Platform Web コンソールまたは CLI (oc) を使用して NotificationsConfiguration CR を設定できます。

2.4.1. Web コンソールを使用した NotificationsConfiguration CR の設定

Web コンソールを使用して、NotificationsConfiguration カスタムリソース (CR) を設定できます。

前提条件

  • cluster-admin 権限で OpenShift Container Platform クラスターにアクセスでき、Web コンソールにログインしている。
  • Red Hat OpenShift GitOps Operator がクラスターにインストールされている。
  • Argo CD インスタンスの通知が有効になっている。詳細は、「Argo CD インスタンスでの通知の有効化」を参照してください。

手順

  1. OpenShift Container Platform Web コンソールの Administrator パースペクティブで、Operators Installed Operators を展開します。
  2. Installed Operators のリストから Red Hat OpenShift GitOps Operator を選択し、NotificationsConfiguration タブをクリックします。
  3. NotificationsConfigurations ページで、default-notifications-configuration をクリックします。
  4. default-notifications-configuration ページで、YAML をクリックし、templatestriggersservicessubscriptions などのサポートされているリソースの設定を追加します。たとえば、コード内の templates の下に、次のサンプル設定を追加します。

    テンプレート設定の例

      template.my-custom-template: |
        message: |
        Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}.

  5. Save をクリックします。
  6. NotificationsConfiguration CR で行われた設定変更が argocd-notifications-cm config map に反映されていることを確認します。

    1. Workloads ConfigMaps に移動します。
    2. argocd-notifications-cm をクリックし、YAML タブを選択します。
    3. YAML タブのページをスクロールして、サポートされているリソースに追加されたサンプル設定を確認します。

2.4.2. CLI を使用した NotificationsConfiguration CR の設定

CLI (oc) を使用して NotificationsConfiguration カスタムリソース (CR) を設定できます。

前提条件

  • cluster-admin 権限を使用して OpenShift Container Platform クラスターにアクセスできる。
  • Red Hat OpenShift GitOps Operator がクラスターにインストールされている。
  • Argo CD インスタンスの通知が有効になっている。詳細は、「Argo CD インスタンスでの通知の有効化」を参照してください。

手順

  1. 次のコマンドを実行して、クラスター内のデフォルトの NotificationsConfiguration CR を編集します。

    $ oc edit notificationsconfiguration default-notifications-configuration -n <namespace>

    ここでは、以下のようになります。

    default-notifications-configuration
    デフォルトの NotificationsConfiguration CR の名前を指定します。
    <namespace>
    namespace の名前を指定します。
  2. CR の templates セクションで、次の例のような設定を追加します。

    テンプレート設定の例

      template.my-custom-template: |
        message: |
        Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}.

  3. 次のコマンドを実行して、argocd-notifications-cm config map の内容を確認します。

    $ oc edit cm argocd-notifications-cm -n <namespace>

    NotificationsConfiguration CR の既存の設定に加えられた変更は、argocd-notifications-cm config map に反映されます。

Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

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

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

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

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

会社概要

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

© 2024 Red Hat, Inc.