
This assumes:
- You have an ArgoCD server up and running. If not, check out my article Install Red Hat OpenShift GitOps Operator using the console (Argo CD)
- You have installed the ArgoCD CLI.
- You are able to log into ArgoCD using the CLI. If not, check out my article Log into ArgoCD using the CLI on OpenShift
The argocd proj list command can be used to list the ArgoCD projects that have been created in the namespace that ArgoCD has been installed in which is typically "argocd" on Kubernetes or openshift-gitops on OpenShift.
~]$ argocd proj list
NAME DESCRIPTION DESTINATIONS SOURCES CLUSTER-RESOURCE-WHITELIST NAMESPACE-RESOURCE-BLACKLIST SIGNATURE-KEYS ORPHANED-RESOURCES DESTINATION-SERVICE-ACCOUNTS
default *,* * */* <none> <none> disabled <none>
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 proj list --server $URL:443 --insecure --grpc-web --config /home/argocd/.config"
'admin:login' logged in successfully
NAME DESCRIPTION DESTINATIONS SOURCES CLUSTER-RESOURCE-WHITELIST NAMESPACE-RESOURCE-BLACKLIST SIGNATURE-KEYS ORPHANED-RESOURCES DESTINATION-SERVICE-ACCOUNTS
default *,* * */* <none> <none> disabled <none>
Likewise, the kubectl (Kubernetes) or oc (OpenShift) get appproject.argoproj.io command on the Kubernetes or OpenShift cluster that ArgoCD is on should return the projects in your currently selected namespace.
~]$ oc get appproject.argoproj.io
NAME AGE
default 50d
Or the --namespace option can be used to list the ArgoCD projects that have been created in a specific namespace.
~]$ oc get appproject.argoproj.io --namespace my-namespace
NAME AGE
default 50d
Likewise the argocd proj get <project name> command can be used.
~]$ argocd proj get default
Name: default
Description:
Destinations: *,*
Repositories: *
Source Namespaces: <none>
Scoped Repositories: https://github.com/argoproj/argocd-example-apps
Allowed Cluster Resources: */*
Scoped Clusters: <none>
Denied Namespaced Resources: <none>
Signature keys: <none>
Orphaned Resources: disabled
The --output json flag can be used to display output as JSON instead of YAML.
~]$ argocd proj get default --output json
{
"metadata": {
"name": "default",
"namespace": "openshift-gitops",
"uid": "34e881f3-0ec6-44e6-a4d2-9971361004b6",
"resourceVersion": "374751652",
"generation": 1,
"creationTimestamp": "2024-11-26T02:28:06Z",
"managedFields": [
{
"manager": "argocd-server",
"operation": "Update",
"apiVersion": "argoproj.io/v1alpha1",
"time": "2024-11-26T02:28:06Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:spec": {
".": {},
"f:clusterResourceWhitelist": {},
"f:destinations": {},
"f:sourceRepos": {}
},
"f:status": {}
}
}
]
},
"spec": {
"sourceRepos": [
"*"
],
"destinations": [
{
"server": "*",
"namespace": "*"
}
],
"clusterResourceWhitelist": [
{
"group": "*",
"kind": "*"
}
]
},
"status": {}
}
Did you find this article helpful?
If so, consider buying me a coffee over at