Files
SnarfCode/scripts/check_argocd_status.py

22 lines
1006 B
Python

import paramiko
def main():
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('140.44.4.41', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
cmd = "kubectl get pod -n infrastructure -l app.kubernetes.io/name=argocd-server -o jsonpath='{.items[0].spec.containers[*].name}'"
stdin, stdout, stderr = ssh.exec_command(cmd)
container_name = stdout.read().decode().strip()
print("Container name:", container_name)
# Check cluster list via argocd CLI inside the server pod
# In argocd pod, the binary 'argocd' is usually available or we can check via curl localhost:8080/api/v1/clusters
stdin, stdout, stderr = ssh.exec_command(f"kubectl exec -n infrastructure deployment/argocd-server -c {container_name} -- curl -s http://localhost:8080/api/v1/clusters")
print("API clusters response:", stdout.read().decode())
ssh.close()
if __name__ == '__main__':
main()