import paramiko import sys import time sys.stdout.reconfigure(encoding='utf-8') key_path = r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet' ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect("140.44.4.41", username="root", key_filename=key_path, timeout=10) print("1. Triggering ArgoCD sync on spaceport-semaphore...") # If argocd CLI or kubectl apply stdin, stdout, stderr = ssh.exec_command("k3s kubectl apply -f C:/Users/Snarf/OneDrive/Desktop/code/SnarfCode/homelab-gitops-repo/manifests/spaceport/semaphore/semaphore.yaml" if False else "k3s kubectl get pods -n infrastructure") # Pull latest manifest via git in gitops repo or apply directly with open(r"C:\Users\Snarf\OneDrive\Desktop\code\SnarfCode\homelab-gitops-repo\manifests\spaceport\semaphore\semaphore.yaml", "r", encoding="utf-8") as f: manifest_content = f.read() stdin, stdout, stderr = ssh.exec_command("k3s kubectl apply -f - --server-side=true") stdin.write(manifest_content) stdin.channel.shutdown_write() print("Apply output:", stdout.read().decode()) err = stderr.read().decode() if err: print("Apply stderr:", err) # Restart pod to pick up new spec immediately stdin, stdout, stderr = ssh.exec_command("k3s kubectl rollout restart deployment/semaphore -n infrastructure") print(stdout.read().decode()) print("Waiting for rollout...") stdin, stdout, stderr = ssh.exec_command("k3s kubectl rollout status deployment/semaphore -n infrastructure --timeout=90s") print(stdout.read().decode()) # Verify new pod env stdin, stdout, stderr = ssh.exec_command("k3s kubectl get pods -n infrastructure -l app.kubernetes.io/name=semaphore -o jsonpath='{.items[0].metadata.name}'") pod = stdout.read().decode().strip() print(f"Active pod: {pod}") stdin, stdout, stderr = ssh.exec_command(f"k3s kubectl exec -n infrastructure {pod} -- env | grep SEMAPHORE_OIDC_PROVIDERS") print("Live env:\n", stdout.read().decode()) ssh.close()