Bootstrap FreeKB - ArgoCD - Remove repo using the CLI
ArgoCD - Remove repo using the CLI

Updated:   |  ArgoCD articles

This assumes:

The argocd repo list command can be used to list the repo's you have added to ArgoCD.

~]$ argocd repo list
TYPE  NAME                 REPO                                             INSECURE  OCI    LFS    CREDS  STATUS      MESSAGE  PROJECT
git   argocd-example-apps  https://github.com/argoproj/argocd-example-apps  false     false  false  false  Successful           default

 

The kubectl (Kubernetes) or oc (OpenShift) get secret command with the --output jsonpath and base64 --decode command can be used to display the name of the repo in ArgoCd, the ArgoCD project that the repo is configured to use, the repo type, the repo URL, 

~]$ oc get secret repo-38486771 --namespace openshift-gitops --output jsonpath="{.data.name}" | base64 --decode
bar

~]$ oc get secret repo-38486771 --namespace openshift-gitops --output jsonpath="{.data.project}" | base64 --decode
default

 ~]$ oc get secret repo-38486771 --namespace openshift-gitops --output jsonpath="{.data.type}" | base64 --decode
git

~]$ oc get secret repo-38486771 --namespace openshift-gitops --output jsonpath="{.data.url}" | base64 --decode
https://github.com/foo/bar

 

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; argocd repo list --server $URL:443 --insecure --grpc-web --config /home/argocd/.config"
'admin:login' logged in successfully
TYPE  NAME                 REPO                                             INSECURE  OCI    LFS    CREDS  STATUS      MESSAGE  PROJECT
git   argocd-example-apps  https://github.com/argoproj/argocd-example-apps  false     false  false  false  Successful           default

 

Likewise the argocd repo rm <repo url> command can be used to remove the repo from ArgoCD.

~]$ argocd repo rm https://github.com/foo/bar
TYPE  NAME                 REPO                           INSECURE  OCI    LFS    CREDS  STATUS      MESSAGE  PROJECT
git   argocd-example-apps  https://github.com/foo/bar    false     false  false  false  Successful           default

 

Or the kubectl (Kubernetes) or oc (OpenShift) delete secret command can be used to delete the secret for the repo you want to remove from ArgoCD.

oc delete secret repo-38486771 --namespace openshift-gitops

 

 




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 8a53e9 in the box below so that we can be sure you are a human.