此内容没有您所选择的语言版本。
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.
		
				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 argocdCLI.
- You have logged in to Argo CD instance.
Procedure
- Get the - adminaccount password for the Argo CD server:- ADMIN_PASSWD=$(oc get secret openshift-gitops-cluster -n openshift-gitops -o jsonpath='{.data.admin\.password}' | base64 -d)- $ ADMIN_PASSWD=$(oc get secret openshift-gitops-cluster -n openshift-gitops -o jsonpath='{.data.admin\.password}' | base64 -d)- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Get the Argo CD server URL: - SERVER_URL=$(oc get routes openshift-gitops-server -n openshift-gitops -o jsonpath='{.status.ingress[0].host}')- $ SERVER_URL=$(oc get routes openshift-gitops-server -n openshift-gitops -o jsonpath='{.status.ingress[0].host}')- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Log in to the Argo CD server by using the - adminaccount 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}- $ argocd login --username admin --password ${ADMIN_PASSWD} ${SERVER_URL}- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example - argocd login --username admin --password '<password>' openshift-gitops.openshift-gitops.apps-crc.testing - $ argocd login --username admin --password '<password>' openshift-gitops.openshift-gitops.apps-crc.testing- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Verify that you are able to run - argocdcommands in the default mode by listing all applications:- argocd app list - $ argocd app list- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 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 - NAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY CONDITIONS REPO PATH TARGET- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create an application in the default mode: - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Label the - spring-petclinicdestination namespace to be managed by the- openshif-gitopsArgo CD instance:- oc label ns spring-petclinic "argocd.argoproj.io/managed-by=openshift-gitops" - $ oc label ns spring-petclinic "argocd.argoproj.io/managed-by=openshift-gitops"- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- List the available applications to confirm that the application is created successfully and repeat the command until the application has the - Healthyand- Syncedstatuses:- argocd app list - $ argocd app list- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
				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 argocdCLI.
Procedure
- Log in to the OpenShift Container Platform cluster by using the - ocCLI tool:- oc login -u <username> -p <password> <server_url> - $ oc login -u <username> -p <password> <server_url>- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example - oc login -u kubeadmin -p '<password>' https://api.crc.testing:6443 - $ oc login -u kubeadmin -p '<password>' https://api.crc.testing:6443- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Check whether the context is set correctly in the - kubeconfigfile:- oc config current-context - $ oc config current-context- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Set the default namespace of the current context to - openshift-gitops:- oc config set-context --current --namespace openshift-gitops - $ oc config set-context --current --namespace openshift-gitops- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Set the following environment variable to override the Argo CD component names: - export ARGOCD_REPO_SERVER_NAME=openshift-gitops-repo-server - $ export ARGOCD_REPO_SERVER_NAME=openshift-gitops-repo-server- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Verify that you are able to run - argocdcommands in- coremode by listing all applications:- argocd app list --core - $ argocd app list --core- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 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 - NAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY CONDITIONS REPO PATH TARGET- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create an application in - coremode:- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Label the - spring-petclinicdestination namespace to be managed by the- openshif-gitopsArgo CD instance:- oc label ns spring-petclinic "argocd.argoproj.io/managed-by=openshift-gitops" - $ oc label ns spring-petclinic "argocd.argoproj.io/managed-by=openshift-gitops"- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- List the available applications to confirm that the application is created successfully and repeat the command until the application has the - Healthyand- Syncedstatuses:- argocd app list --core - $ argocd app list --core- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow