25 lines
971 B
Python
25 lines
971 B
Python
import paramiko
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
ssh.connect('140.44.4.11', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=8)
|
|
|
|
for pod in ['pihole-85b7bd696d-ltrvg', 'technitium-dns-6dcf8fc9f6-mxd7p']:
|
|
cmd = f'kubectl patch pod -n infra {pod} -p "{{\\"metadata\\":{{\\"finalizers\\":null}}}}" --type=merge'
|
|
stdin, stdout, stderr = ssh.exec_command(cmd)
|
|
print(f"Patch {pod}:", stdout.read().decode().strip(), stderr.read().decode().strip())
|
|
|
|
del_cmd = f'kubectl delete pod -n infra {pod} --force --grace-period=0'
|
|
stdin, stdout, stderr = ssh.exec_command(del_cmd)
|
|
print(f"Delete {pod}:", stdout.read().decode().strip(), stderr.read().decode().strip())
|
|
|
|
# Check remaining pods in infra
|
|
_, out, _ = ssh.exec_command('kubectl get pods -n infra')
|
|
print("\nInfra pods:\n", out.read().decode())
|
|
|
|
ssh.close()
|
|
|