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

Chapter 2. Creating an application by using the GitOps CLI


With Argo CD, you can create your applications on an OpenShift Container Platform cluster by using the GitOps argocd CLI.

2.1. Creating an application in the default mode by using the GitOps CLI

You can create applications in the default mode by using the GitOps argocd CLI.

Prerequisites

  • You have installed the Red Hat OpenShift GitOps Operator on your OpenShift Container Platform cluster.
  • You have installed the OpenShift CLI (oc).
  • You have installed the Red Hat OpenShift GitOps argocd CLI.
  • You have logged in to Argo CD instance.

Procedure

  1. Get the admin account password for the Argo CD server:

    $ ADMIN_PASSWD=$(oc get secret openshift-gitops-cluster -n openshift-gitops -o jsonpath='{.data.admin\.password}' | base64 -d)
    Copy to Clipboard Toggle word wrap
  2. Get the Argo CD server URL:

    $ SERVER_URL=$(oc get routes openshift-gitops-server -n openshift-gitops -o jsonpath='{.status.ingress[0].host}')
    Copy to Clipboard Toggle word wrap
  3. Log in to the Argo CD server by using the admin account password and enclosing it in single quotes:

    Important

    Enclosing the password in single quotes ensures that special characters, such as $, are not misinterpreted by the shell. Always use single quotes to enclose the literal value of the password.

    $ argocd login --username admin --password ${ADMIN_PASSWD} ${SERVER_URL}
    Copy to Clipboard Toggle word wrap

    Example

    $ argocd login --username admin --password '<password>' openshift-gitops.openshift-gitops.apps-crc.testing
    Copy to Clipboard Toggle word wrap

  4. Verify that you are able to run argocd commands in the default mode by listing all applications:

    $ argocd app list
    Copy to Clipboard Toggle word wrap

    If the configuration is correct, then existing applications will be listed with the following header:

    Sample output

    NAME CLUSTER NAMESPACE  PROJECT  STATUS  HEALTH   SYNCPOLICY  CONDITIONS  REPO PATH TARGET
    Copy to Clipboard Toggle word wrap

  5. Create an application in the default mode:

    $ argocd app create app-spring-petclinic \
        --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=true
    Copy to Clipboard Toggle word wrap
  6. Label the spring-petclinic destination namespace to be managed by the openshif-gitops Argo CD instance:

    $ oc label ns spring-petclinic "argocd.argoproj.io/managed-by=openshift-gitops"
    Copy to Clipboard Toggle word wrap
  7. List the available applications to confirm that the application is created successfully and repeat the command until the application has the Healthy and Synced statuses:

    $ argocd app list
    Copy to Clipboard Toggle word wrap

2.2. Creating an application in core mode by using the GitOps CLI

You can create applications in core mode by using the GitOps argocd CLI.

Prerequisites

  • You have installed the Red Hat OpenShift GitOps Operator on your OpenShift Container Platform cluster.
  • You have installed the OpenShift CLI (oc).
  • You have installed the Red Hat OpenShift GitOps argocd CLI.

Procedure

  1. Log in to the OpenShift Container Platform cluster by using the oc CLI tool:

    $ oc login -u <username> -p <password> <server_url>
    Copy to Clipboard Toggle word wrap

    Example

    $ oc login -u kubeadmin -p '<password>' https://api.crc.testing:6443
    Copy to Clipboard Toggle word wrap

  2. Check whether the context is set correctly in the kubeconfig file:

    $ oc config current-context
    Copy to Clipboard Toggle word wrap
  3. Set the default namespace of the current context to openshift-gitops:

    $ oc config set-context --current --namespace openshift-gitops
    Copy to Clipboard Toggle word wrap
  4. Set the following environment variable to override the Argo CD component names:

    $ export ARGOCD_REPO_SERVER_NAME=openshift-gitops-repo-server
    Copy to Clipboard Toggle word wrap
  5. Verify that you are able to run argocd commands in core mode by listing all applications:

    $ argocd app list --core
    Copy to Clipboard Toggle word wrap

    If the configuration is correct, then existing applications will be listed with the following header:

    Sample output

    NAME CLUSTER NAMESPACE  PROJECT  STATUS  HEALTH   SYNCPOLICY  CONDITIONS  REPO PATH TARGET
    Copy to Clipboard Toggle word wrap

  6. Create an application in core mode:

    $ 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=true
    Copy to Clipboard Toggle word wrap
  7. Label the spring-petclinic destination namespace to be managed by the openshif-gitops Argo CD instance:

    $ oc label ns spring-petclinic "argocd.argoproj.io/managed-by=openshift-gitops"
    Copy to Clipboard Toggle word wrap
  8. List the available applications to confirm that the application is created successfully and repeat the command until the application has the Healthy and Synced statuses:

    $ argocd app list --core
    Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

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

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

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

Red Hat 소개

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

Theme

© 2025 Red Hat