Files
SnarfCode/scripts/cleanup_spaceport_svclb.py

26 lines
951 B
Python

import paramiko
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)
with open(r'homelab-gitops-repo/manifests/spaceport/dns/dns-stack.yaml', 'r') as f:
manifest_content = f.read()
stdin, stdout, stderr = ssh.exec_command('k3s kubectl apply -f -')
stdin.write(manifest_content)
stdin.channel.shutdown_write()
print("Apply:", stdout.read().decode())
stdin, stdout, stderr = ssh.exec_command('k3s kubectl delete svc -n dns pihole-web-vip 2>/dev/null || true')
print("Delete old svc:", stdout.read().decode())
# Check pending pods on Spaceport now
stdin, stdout, stderr = ssh.exec_command("k3s kubectl get pods -A --field-selector=status.phase!=Running,status.phase!=Succeeded --no-headers")
print("Pending/failing pods on Spaceport:")
print(stdout.read().decode())
ssh.close()