Bootstrap FreeKB - ArgoCD - Log into ArgoCD using the CLI on OpenShift
ArgoCD - Log into ArgoCD using the CLI on OpenShift

Updated:   |  ArgoCD articles

This assumes you have an ArgoCD server up and running. If not, check out my article FreeKB - OpenShift - Install Red Hat OpenShift GitOps Operator using the console (Argo CD).

You can.

This also assumes you have installed the ArgoCD CLI. The oc get routes command can be used to return the ArgoCD login URL.

SERVER_URL=$(oc get routes openshift-gitops-server --namespace openshift-gitops --output jsonpath='{.status.ingress[0].host}')

 

The oc get secrets command can be used to return the default admin password.

ADMIN_PASSWD=$(oc get secret openshift-gitops-cluster --namespace openshift-gitops --output jsonpath='{.data.admin\.password}' | base64 --decode)

 

The argocd login command can then be used to log into ArgoCD.

argocd login --username admin --password ${ADMIN_PASSWD} ${SERVER_URL}

 

Or on the Kubernetes or OpenShift cluster that ArgoCD is in the kubectl (Kubernetes) or oc (OpenShift) exec command can be used to run the argocd cluster list command in the ArgoCD server pod. It is noteworthy that by default the argocd login command will create the hidden .config file in the root directory of the operating system /.config and only root has permission to create files in the root directory of the operating system thus the --config /home/argocd/.config option is used so that the hidden .config file is create in our users home directory.

~]$ SERVER_POD=$(oc get pod --namespace openshift-gitops --selector=app.kubernetes.io/name=openshift-gitops-server --output custom-columns=POD:.metadata.name --no-headers)
~]$ ADMIN_PASSWD=$(oc get secret openshift-gitops-cluster --namespace openshift-gitops --output jsonpath='{.data.admin\.password}' | base64 --decode)
~]$ URL=$(oc get routes --namespace openshift-gitops --selector=app.kubernetes.io/name=openshift-gitops-server --output jsonpath="{.items[*].spec.host}")

~]$ oc exec $SERVER_POD --namespace openshift-gitops -- /bin/bash -c "argocd login --username admin --password $ADMIN_PASSWD $URL:443 --insecure --grpc-web --config /home/argocd/.config"
'admin:login' logged in successfully

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter de0711 in the box below so that we can be sure you are a human.