6.2. 在 MicroShift 上创建 GitOps 应用程序
您可以创建自定义 YAML 配置来部署和管理 MicroShift 服务中的应用程序。要安装运行 GitOps 应用程序所需的软件包,请参阅"从 RPM 软件包安装 GitOps Argo CD 清单"中的文档。
先决条件
-
已安装
microshift-gitops
软件包,并且 Argo CD pod 在openshift-gitops
命名空间中运行。
流程
创建 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=true
spring-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=true
要部署 YAML 文件中定义的应用程序,请运行以下命令:
$ 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