Files
SnarfCode/scripts/investigate_dns_stubs.py

35 lines
1.3 KiB
Python

import paramiko
import sys
sys.stdout.reconfigure(encoding='utf-8')
key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
def check(host, name):
print(f"\n=================== {name} ({host}) ===================")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(host, username="root", key_filename=key_path, timeout=10)
print("\n--- Namespaces ---")
stdin, stdout, stderr = c.exec_command("k3s kubectl get ns")
print(stdout.read().decode('utf-8'))
print("\n--- Services with port 53 or pihole/technitium/dns in all namespaces ---")
stdin, stdout, stderr = c.exec_command("k3s kubectl get svc -A | grep -E '53|dns|pihole|technitium'")
print(stdout.read().decode('utf-8'))
print("\n--- Deployments / StatefulSets with dns/pihole/technitium ---")
stdin, stdout, stderr = c.exec_command("k3s kubectl get deploy,sts,ds -A | grep -E 'pihole|technitium|unbound|dns'")
print(stdout.read().decode('utf-8'))
print("\n--- MetalLB IPAddressPool or Services with LoadBalancer ---")
stdin, stdout, stderr = c.exec_command("k3s kubectl get ipaddresspool -A 2>/dev/null; k3s kubectl get svc -A --field-selector spec.type=LoadBalancer")
print(stdout.read().decode('utf-8'))
c.close()
check("140.44.4.11", "Aerodrome")
check("140.44.4.41", "Spaceport")