
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
ArgoCD sits between your version control system (such as GitHub) and your Kubernetes or OpenShift clusters and is used to create resources (such as deployments, pods, services, routes, config maps and secrets) in a particular namespace in your Kubernetes or OpenShift clusters. Almost always, this means you will have YAML files for your various Kubernetes or OpenShift resources in your version control system, such as YAML files for your Kubernetes or OpenShift deployments, YAML files for your Kubernetes or OpenShift secrets, YAML files for your Kubernetes or OpenShift services, et cetera, and ArgoCD will create the corresponding resources in your Kubernetes or OpenShift clusters using the YAML files in your version control system. ArgoCD will also ensure the resources on your Kubernetes or OpenShift clusters remain in sync with their corresponding YAML files in your version control system.

The argocd cluster list command can be used to list your ArgoCD Clusters.
~]$ argocd cluster list
SERVER NAME VERSION STATUS MESSAGE PROJECT
https://api.dev.openshift.example.com:6443 dev-cluster 1.27 Successful
https://api.stage.openshift.example.com:6443 stage-cluster 1.27 Successful
https://api.prod.openshift.example.com:6443 prod-cluster 1.27 Successful
https://kubernetes.default.svc in-cluster 1.27 Successful
Or in the ArgoCD console at Settings > Clusters.

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 cluster list --server $URL:443 --insecure --grpc-web --config /home/argocd/.config"
'admin:login' logged in successfully
SERVER NAME VERSION STATUS MESSAGE PROJECT
https://api.dev.openshift.example.com:6443 dev-cluster 1.27 Successful
https://api.stage.openshift.example.com:6443 stage-cluster 1.27 Successful
https://api.prod.openshift.example.com:6443 prod-cluster 1.27 Successful
https://kubernetes.default.svc in-cluster 1.27 Successful
Likewise the argocd cluster get <cluster name> command can be used to display a little bit more information about the cluster.
~]$ argocd cluster get in-cluster
config:
tlsClientConfig:
insecure: false
connectionState:
attemptedAt: "2024-12-19T02:47:08Z"
message: Cluster has no applications and is not being monitored.
status: Unknown
info:
applicationsCount: 0
cacheInfo: {}
connectionState:
attemptedAt: "2024-12-19T02:47:08Z"
message: Cluster has no applications and is not being monitored.
status: Unknown
name: in-cluster
server: https://kubernetes.default.svc
The --output json flag can be used to display output as JSON instead of YAML.
~]$ argocd cluster get in-cluster --output json
{
"server": "https://kubernetes.default.svc",
"name": "in-cluster",
"config": {
"tlsClientConfig": {
"insecure": false
}
},
"connectionState": {
"status": "Unknown",
"message": "Cluster has no applications and is not being monitored.",
"attemptedAt": "2024-12-19T02:54:48Z"
},
"info": {
"connectionState": {
"status": "Unknown",
"message": "Cluster has no applications and is not being monitored.",
"attemptedAt": "2024-12-19T02:54:48Z"
},
"cacheInfo": {},
"applicationsCount": 0
}
}
Did you find this article helpful?
If so, consider buying me a coffee over at