2.2. GitOps CLI を使用したコアモードでのアプリケーションの作成
GitOps argocd CLI を使用して、core モードでアプリケーションを作成できます。
前提条件
- Red Hat OpenShift GitOps Operator が OpenShift Container Platform クラスターにインストールされている。
-
OpenShift CLI (
oc) がインストールされている。 -
Red Hat OpenShift GitOps
argocdCLI がインストールされている。
手順
ocCLI ツールを使用して OpenShift Container Platform クラスターにログインします。$ oc login -u <username> -p <password> <server_url>例
$ oc login -u kubeadmin -p '<password>' https://api.crc.testing:6443コンテキストが
kubeconfigファイルで正しく設定されているかどうかを確認します。$ oc config current-context現在のコンテキストのデフォルトの namespace を
openshift-gitopsに設定します。$ oc config set-context --current --namespace openshift-gitops次の環境変数を設定して、Argo CD コンポーネント名をオーバーライドします。
$ export ARGOCD_REPO_SERVER_NAME=openshift-gitops-repo-serverすべてのアプリケーションを一覧表示して、
coreモードでargocdコマンドを実行できることを確認します。$ argocd app list --core設定が正しい場合は、既存のアプリケーションが次のヘッダーとともにリストされます。
出力例
NAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY CONDITIONS REPO PATH TARGETcoreモードでアプリケーションを作成します。$ argocd app create app-spring-petclinic --core \ --repo https://github.com/redhat-developer/openshift-gitops-getting-started.git \ --path app \ --revision main \ --dest-server https://kubernetes.default.svc \ --dest-namespace spring-petclinic \ --directory-recurse \ --sync-policy automated \ --self-heal \ --sync-option Prune=true \ --sync-option CreateNamespace=trueopenshif-gitopsArgo CD インスタンスによって管理されるspring-petclinic宛先 namespace にラベルを付けます。$ oc label ns spring-petclinic "argocd.argoproj.io/managed-by=openshift-gitops"使用可能なアプリケーションをリストして、アプリケーションが正常に作成されたことを確認し、アプリケーションのステータスが
HealthyおよびSyncedになるまでコマンドを繰り返します。$ argocd app list --core