feat: add cluster management and audit utility scripts
This commit is contained in:
64
scripts/phase1_cleanup_stubs.py
Normal file
64
scripts/phase1_cleanup_stubs.py
Normal file
@@ -0,0 +1,64 @@
|
||||
import paramiko
|
||||
import sys
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
|
||||
key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
|
||||
|
||||
def run_commands(host, ns, resources, desc):
|
||||
print(f"\n=======================================================")
|
||||
print(f"[{desc}] Cleaning up legacy DNS stubs on {host} ({ns})...")
|
||||
print(f"=======================================================")
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(host, username="root", key_filename=key_path, timeout=10)
|
||||
|
||||
for r in resources:
|
||||
cmd = f"k3s kubectl -n {ns} delete {r} --ignore-not-found=true"
|
||||
print(f">>> {cmd}")
|
||||
stdin, stdout, stderr = c.exec_command(cmd)
|
||||
out = stdout.read().decode('utf-8').strip()
|
||||
err = stderr.read().decode('utf-8').strip()
|
||||
if out: print(" ", out)
|
||||
if err: print(" ERR:", err)
|
||||
|
||||
print("\n--- Verifying remaining services and deployments ---")
|
||||
stdin, stdout, stderr = c.exec_command(f"k3s kubectl -n {ns} get deploy,svc,pvc | grep -E 'pihole|technitium'")
|
||||
res = stdout.read().decode('utf-8').strip()
|
||||
if res:
|
||||
print("Lingering items:\n", res)
|
||||
else:
|
||||
print("Clean! No lingering pihole or technitium resources found.")
|
||||
|
||||
c.close()
|
||||
|
||||
# 1. Aerodrome (ns: infra)
|
||||
aero_resources = [
|
||||
"deployment pihole",
|
||||
"deployment technitium-dns",
|
||||
"service pihole-dns-tcp",
|
||||
"service pihole-dns-udp",
|
||||
"service pihole-web",
|
||||
"service technitium-npm-vip-service",
|
||||
"pvc pihole",
|
||||
"pvc technitium-longhorn-pvc",
|
||||
"configmap pihole-custom-dns",
|
||||
"configmap technitium-config"
|
||||
]
|
||||
run_commands("140.44.4.11", "infra", aero_resources, "Aerodrome")
|
||||
|
||||
# 2. Spaceport (ns: infrastructure)
|
||||
space_resources = [
|
||||
"deployment pihole",
|
||||
"deployment technitium-dns",
|
||||
"service pihole-dns-tcp",
|
||||
"service pihole-dns-udp",
|
||||
"service pihole-web",
|
||||
"service technitium-service",
|
||||
"pvc pihole",
|
||||
"pvc technitium-longhorn-pvc",
|
||||
"configmap pihole-custom-dns",
|
||||
"configmap technitium-config"
|
||||
]
|
||||
run_commands("140.44.4.41", "infrastructure", space_resources, "Spaceport")
|
||||
|
||||
Reference in New Issue
Block a user