39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
import paramiko
|
|
import sys
|
|
import time
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
|
|
|
|
def apply_to_cluster(ip, name, manifest_path):
|
|
print(f"Connecting to {name} ({ip})...")
|
|
with open(manifest_path, "r", encoding="utf-8") as f:
|
|
content = f.read()
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(ip, username="root", key_filename=key_path, timeout=10)
|
|
|
|
stdin, stdout, stderr = c.exec_command("k3s kubectl apply -f -")
|
|
stdin.write(content)
|
|
stdin.channel.shutdown_write()
|
|
|
|
out = stdout.read().decode('utf-8')
|
|
err = stderr.read().decode('utf-8')
|
|
print(f"[{name}] Apply Output:\n{out}")
|
|
if err.strip():
|
|
print(f"[{name}] Apply Error:\n{err}")
|
|
c.close()
|
|
|
|
aero_path = r"c:\Users\Snarf\OneDrive\Desktop\code\SnarfCode\homelab-gitops-repo\manifests\aerodrome\dns\dns-stack.yaml"
|
|
space_path = r"c:\Users\Snarf\OneDrive\Desktop\code\SnarfCode\homelab-gitops-repo\manifests\spaceport\dns\dns-stack.yaml"
|
|
|
|
apply_to_cluster("140.44.4.11", "Aerodrome", aero_path)
|
|
time.sleep(2)
|
|
apply_to_cluster("140.44.4.41", "Spaceport", space_path)
|
|
print("Finished applying manifests to both clusters!")
|
|
|
|
|
|
|