이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 6. Automating application management with the GitOps controller


GitOps with Argo CD for MicroShift is a lightweight, optional add-on controller derived from the Red Hat OpenShift GitOps Operator. GitOps for MicroShift uses the command-line interface (CLI) of Argo CD to interact with the GitOps controller that acts as the declarative GitOps engine. You can consistently configure and deploy Kubernetes-based infrastructure and applications across clusters and development lifecycles.

6.1. What you can do with the GitOps agent

By using the GitOps with Argo CD agent with MicroShift, you can utilize the following principles:

  • Implement application lifecycle management.

    • Create and manage your clusters and application configuration files using the core principles of developing and maintaining software in a Git repository.
    • You can update the single repository and GitOps automates the deployment of new applications or updates to existing ones.
    • For example, if you have 1,000 edge devices, each using MicroShift and a local GitOps agent, you can easily add or update an application on all 1,000 devices with just one change in your central Git repository.
  • The Git repository contains a declarative description of the infrastructure you need in your specified environment and contains an automated process to make your environment match the described state.
  • You can also use the Git repository as an audit trail of changes so that you can create processes based on Git flows such as review and approval for merging pull requests that implement configuration changes.

6.2. Creating GitOps applications on MicroShift

You can create a custom YAML configuration to deploy and manage applications in your MicroShift service. To install the necessary packages to run GitOps applications, follow the documentation in "Installing the GitOps Argo CD manifests from an RPM package".

Prerequisites

  • You installed the microshift-gitops packages.
  • The Argo CD pods are running in the openshift-gitops namespace.

Procedure

  1. Create a YAML file and add your customized configurations for the application:

    Example YAML for a spring-petclinic application

    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

  2. To deploy the applications defined in the YAML file, run the following command:

    $ oc apply -f <my_app.yaml> 1
    1
    Replace <my_app.yaml> with the name of your application YAML.

Verification

  • To verify your application is deployed and synced, run the following command:

    $ oc get applications -A

    It might take a few minutes for the application to show the Healthy status.

    Example output

    NAMESPACE          NAME               SYNC STATUS   HEALTH STATUS
    openshift-gitops   spring-petclinic   Synced        Healthy

6.3. Limitations of using the GitOps agent with MicroShift

GitOps with Argo CD for MicroShift has the following differences from the Red Hat OpenShift GitOps Operator:

  • The gitops-operator component is not used with MicroShift.
  • To maintain the small resource use of MicroShift, the Argo CD web console is not available. You can use the Argo CD CLI.
  • Because MicroShift is single-node, there is no multi-cluster support. Each instance of MicroShift is paired with a local GitOps agent.
  • The oc adm must-gather command is not available in MicroShift.

6.4. Troubleshooting GitOps

If you have problems with your GitOps controller, you can use the OpenShift CLI (oc) tool.

6.4.1. Debugging GitOps with oc adm inspect

You can debug GitOps by using the OpenShift CLI (oc).

Prerequisites

  • The oc command line tool is installed.

Procedure

  1. Run the oc adm inspect command when in the GitOps namespace:

    $ oc adm inspect ns/openshift-gitops

    Example output

    Gathering data for ns/openshift-gitops...
    W0501 20:34:35.978508 57625 util.go:118] the server doesn't have a resource type egressfirewalls, skipping the inspection
    W0501 20:34:35.980881 57625 util.go:118] the server doesn't have a resource type egressqoses, skipping the inspection
    W0501 20:34:36.040664 57625 util.go:118] the server doesn't have a resource type servicemonitors, skipping the inspection
    Wrote inspect data to inspect.local.2673575938140296280.

Next steps

  • If oc adm inspect did not provide the information you need, you can run an sos report.

6.5. Additional resources

Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.