Argo CD アプリケーション


Red Hat OpenShift GitOps 1.9

Argo CD ダッシュボードまたは oc ツールを使用した OpenShift クラスター上でのアプリケーションの作成とデプロイ

Red Hat OpenShift Documentation Team

概要

このドキュメントでは、Argo CD ダッシュボードまたは oc ツールを使用してアプリケーションを作成し、OpenShift クラスターにデプロイする手順を説明します。Argo CD の自己修復動作を検証する方法についても説明します。

第1章 Argo CD を使用した Spring Boot アプリケーションのデプロイ

Argo CD を使用すると、Argo CD ダッシュボードまたは oc ツールを使用して、アプリケーションを OpenShift クラスターにデプロイできます。

1.1. 前提条件

  • Red Hat OpenShift GitOps がクラスターにインストールされている。
  • Argo CD インスタンスにログインしている。

1.2. Argo CD ダッシュボードを使用したアプリケーションの作成

Argo CD は、アプリケーションを作成できるダッシュボードを提供します。

手順

  1. Argo CD ダッシュボードで、New App をクリックして新規の Argo CD アプリケーションを追加します。
  2. このワークフローでは、以下の設定で spring-petclinic アプリケーションを作成します。

    アプリケーション名
    spring-petclinic
    プロジェクト
    default
    同期ポリシー
    Automatic
    リポジトリー URL
    https://github.com/redhat-developer/openshift-gitops-getting-started
    リビジョン
    HEAD
    パス
    app
    宛先
    https://kubernetes.default.svc
    Namespace
    spring-petclinic
  3. Create をクリックしてアプリケーションを作成します。
  4. Web コンソールの Administrator パースペクティブで、左側のメニューにある AdministrationNamespaces に移動します。
  5. namespace を検索、選択してから Label フィールドに argocd.argoproj.io/managed-by=openshift-gitops を入力し、openshift-gitops namespace にある Argo CD インスタンスが namespace を管理できるようにします。

1.3. oc ツールを使用したアプリケーションの作成

oc ツールを使用して、ターミナルで Argo CD アプリケーションを作成できます。

手順

  1. サンプルアプリケーション をダウンロードします。

    $ git clone git@github.com:redhat-developer/openshift-gitops-getting-started.git
    Copy to Clipboard Toggle word wrap
  2. アプリケーションを作成します。

    $ oc create -f openshift-gitops-getting-started/argo/app.yaml
    Copy to Clipboard Toggle word wrap
  3. oc get コマンドを実行して、作成されたアプリケーションを確認します。

    $ oc get application -n openshift-gitops
    Copy to Clipboard Toggle word wrap
  4. アプリケーションがデプロイされている namespace にラベルを追加し、openshift-gitops namespace の Argo CD インスタンスが管理できるようにします。

    $ oc label namespace spring-petclinic argocd.argoproj.io/managed-by=openshift-gitops
    Copy to Clipboard Toggle word wrap

1.4. Argo CD の自己修復動作の確認

Argo CD は、デプロイされたアプリケーションの状態を常に監視し、Git の指定されたマニフェストとクラスターのライブの変更の違いを検出し、それらを自動的に修正します。この動作は自己修復として言及されます。

Argo CD で自己修復動作をテストし、確認することができます。

前提条件

  • サンプル app-spring-petclinic アプリケーションがデプロイされ、設定されている。

手順

  1. Argo CD ダッシュボードで、アプリケーションに Synced ステータスがあることを確認します。
  2. Argo CD ダッシュボードの app-spring-petclinic タイルをクリックし、クラスターにデプロイされたアプリケーションのリソースを表示します。
  3. OpenShift Container Platform Web コンソールで、Developer パースペクティブに移動します。
  4. Spring PetClinic デプロイメントを変更し、Git リポジトリーの app/ ディレクトリーに変更をコミットします。Argo CD は変更をクラスターに自動的にデプロイします。

    1. OpenShift GitOps 開始のリポジトリー をフォークします。
    2. deployment.yaml ファイルで failureThreshold の値を 5 に変更します。
    3. デプロイメントクラスターで、以下のコマンドを実行し、failureThreshold フィールドの値を確認します。

      $ oc edit deployment spring-petclinic -n spring-petclinic
      Copy to Clipboard Toggle word wrap
  5. OpenShift Container Platform Web コンソールでアプリケーションを監視している間に、クラスターでデプロイメントを変更し、これを 2 つの Pod にスケールアップして自己修復動作をテストします。

    1. 以下のコマンドを実行してデプロイメントを変更します。

      $ oc scale deployment spring-petclinic --replicas 2  -n spring-petclinic
      Copy to Clipboard Toggle word wrap
    2. OpenShift Container Platform Web コンソールでは、デプロイメントは 2 つの Pod にスケールアップし、すぐに再び 1 つの Pod にスケールダウンすることに注意してください。Argo CD は Git リポジトリーとの差異を検知し、OpenShift Container Platform クラスターでアプリケーションを自動的に修復しました。
  6. Argo CD ダッシュボードで、app-spring-petclinic タイル → APP DETAILSEVENTS をクリックします。EVENTS タブには、以下のイベントが表示されます。Argo CD がクラスターのデプロイメントリソースが同期されていないことを検知し、Git リポジトリーを再同期してこれを修正します。

法律上の通知

Copyright © 2024 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

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

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

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

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

会社概要

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

Theme

© 2025 Red Hat