feat: add homelab deployment configs, documentation, and automation scripts
This commit is contained in:
33
scripts/apply_grafana_dashboards.py
Normal file
33
scripts/apply_grafana_dashboards.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import paramiko
|
||||
import time
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect('140.44.4.11', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
||||
|
||||
def run(cmd):
|
||||
_, o, e = c.exec_command(cmd)
|
||||
out = o.read().decode().strip()
|
||||
err = e.read().decode().strip()
|
||||
return out + ("\nERR: " + err if err else "")
|
||||
|
||||
with open("homelab-gitops-repo/manifests/aerodrome/grafana/grafana.yaml", "r", encoding="utf-8") as f:
|
||||
grafana_yaml = f.read()
|
||||
|
||||
stdin, stdout, stderr = c.exec_command("cat > /tmp/grafana_updated.yaml")
|
||||
stdin.write(grafana_yaml)
|
||||
stdin.close()
|
||||
stdout.channel.recv_exit_status()
|
||||
|
||||
print("Applying Grafana manifests:")
|
||||
print(run("kubectl apply -f /tmp/grafana_updated.yaml"))
|
||||
|
||||
print("\nRestarting Grafana:")
|
||||
print(run("kubectl rollout restart deployment/grafana -n default"))
|
||||
print(run("kubectl rollout status deployment/grafana -n default --timeout=60s"))
|
||||
|
||||
print("\nWaiting for Grafana to finish initialization...")
|
||||
time.sleep(10)
|
||||
|
||||
c.close()
|
||||
|
||||
Reference in New Issue
Block a user