import paramiko import time import sys sys.stdout.reconfigure(encoding='utf-8') key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet" c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("140.44.4.11", username="root", key_filename=key_path, timeout=5) repair_yaml = """apiVersion: v1 kind: Pod metadata: name: dns-repair namespace: dns spec: containers: - name: repair image: busybox command: ["sh", "-c", "ls -la /etc/dns && rm -f /etc/dns/auth.config* && echo AFTER REMOVAL: && ls -la /etc/dns"] volumeMounts: - name: data mountPath: /etc/dns volumes: - name: data persistentVolumeClaim: claimName: technitium-config-pvc restartPolicy: Never """ stdin, stdout, stderr = c.exec_command("cat << 'EOF' | k3s kubectl apply -f -\n" + repair_yaml + "\nEOF\n") print("Apply:", stdout.read().decode('utf-8')) time.sleep(8) stdin, stdout, stderr = c.exec_command("k3s kubectl -n dns logs pod/dns-repair") print("Logs:\n", stdout.read().decode('utf-8')) stdin, stdout, stderr = c.exec_command("k3s kubectl -n dns delete pod dns-repair --wait=false") print("Delete:", stdout.read().decode('utf-8')) # Now scale technitium back up! stdin, stdout, stderr = c.exec_command("k3s kubectl -n dns scale deployment/technitium-dns --replicas=1") print("Scale up:", stdout.read().decode('utf-8')) c.close()