6.2. MicroShift で GitOps アプリケーションの作成
MicroShift サービスでアプリケーションをデプロイおよび管理するためのカスタム YAML 設定を作成できます。GitOps アプリケーションを実行するために必要なパッケージをインストールするには、「RPM パッケージからの GitOps Argo CD マニフェストのインストール」に従ってください。
前提条件
-
microshift-gitopsパッケージがインストールされ、Argo CD Pod がopenshift-gitopsnamespace で実行している。
手順
YAML ファイルを作成し、アプリケーションのカスタマイズされた設定を追加します。
cert-managerアプリケーションの YAML の例kind: AppProject apiVersion: argoproj.io/v1alpha1 metadata: name: default namespace: openshift-gitops spec: clusterResourceWhitelist: - group: '*' kind: '*' destinations: - namespace: '*' server: '*' sourceRepos: - '*' --- apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: cert-manager namespace: openshift-gitops spec: destination: namespace: cert-manager server: https://kubernetes.default.svc project: default source: path: cert-manager repoURL: https://github.com/anandf/microshift-install syncPolicy: automated: {} syncOptions: - CreateNamespace=true - ServerSideApply=truespring-petclinicアプリケーションの YAML の例kind: AppProject apiVersion: argoproj.io/v1alpha1 metadata: name: default namespace: openshift-gitops spec: clusterResourceWhitelist: - group: '*' kind: '*' destinations: - namespace: '*' server: '*' sourceRepos: - '*' --- kind: Application apiVersion: argoproj.io/v1alpha1 metadata: name: spring-petclinic namespace: openshift-gitops spec: destination: namespace: spring-petclinic server: https://kubernetes.default.svc project: default source: directory: recurse: true path: app repoURL: https://github.com/siamaksade/openshift-gitops-getting-started syncPolicy: automated: {} syncOptions: - CreateNamespace=true - ServerSideApply=trueYAML ファイルで定義されたアプリケーションをデプロイするには、次のコマンドを実行します。
$ oc apply -f <filename>.yaml
検証
アプリケーションがデプロイされ、同期されていることを確認するには、次のコマンドを実行します。
$ oc get applications -Aアプリケーションが
Healthyステータスを表示するまで数分かかる場合があります。出力例
NAMESPACE NAME SYNC STATUS HEALTH STATUS openshift-gitops cert-manager Synced Healthy openshift-gitops spring-petclinic Synced Healthy