Files
SnarfCode/scripts/sync_argo_prom.py

18 lines
761 B
Python

import paramiko
import json
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect('140.44.4.41', username='root', password='dietpi', timeout=10)
_, o, _ = c.exec_command("kubectl get applications.argoproj.io aerodrome-prometheus -n infrastructure -o json")
data = json.loads(o.read().decode().strip())
print("Sync status:", data.get("status", {}).get("sync", {}).get("status"))
print("Revision:", data.get("status", {}).get("sync", {}).get("revision"))
# Trigger sync via argocd CLI or patch
_, o, _ = c.exec_command("kubectl patch applications.argoproj.io aerodrome-prometheus -n infrastructure --type merge -p '{\"operation\":{\"sync\":{\"prune\":true}}}'")
print("Trigger sync:", o.read().decode().strip())
c.close()