feat: add infrastructure health check and management automation scripts
This commit is contained in:
48
scripts/apply_coredns_spaceport.py
Normal file
48
scripts/apply_coredns_spaceport.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import paramiko
|
||||
import sys
|
||||
import time
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
|
||||
key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
|
||||
client.connect("140.44.4.41", username="root", key_filename=key_path, timeout=10)
|
||||
|
||||
cm_yaml = """cat << 'EOF' | k3s kubectl apply -f -
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: coredns-custom
|
||||
namespace: kube-system
|
||||
data:
|
||||
snarfnet.override: |
|
||||
hosts {
|
||||
140.44.4.34 aerodrome.snarfnet.net
|
||||
140.44.4.90 harvester.spacedock.snarfnet.net
|
||||
fallthrough
|
||||
}
|
||||
EOF
|
||||
"""
|
||||
|
||||
print("Applying coredns-custom on Spaceport...")
|
||||
stdin, stdout, stderr = client.exec_command(cm_yaml)
|
||||
print(stdout.read().decode('utf-8'))
|
||||
print(stderr.read().decode('utf-8'))
|
||||
|
||||
print("\nRestarting coredns deployment on Spaceport...")
|
||||
client.exec_command("k3s kubectl -n kube-system rollout restart deployment/coredns")
|
||||
client.exec_command("k3s kubectl -n kube-system rollout status deployment/coredns --timeout=60s")
|
||||
|
||||
print("\nRestarting cattle-cluster-agent on Spaceport...")
|
||||
client.exec_command("k3s kubectl -n cattle-system rollout restart deployment/cattle-cluster-agent")
|
||||
client.exec_command("k3s kubectl -n cattle-system rollout status deployment/cattle-cluster-agent --timeout=60s")
|
||||
|
||||
time.sleep(5)
|
||||
print("\nChecking cattle-cluster-agent logs:")
|
||||
stdin, stdout, stderr = client.exec_command("k3s kubectl -n cattle-system logs -l app=cattle-cluster-agent --tail=25")
|
||||
print(stdout.read().decode('utf-8'))
|
||||
|
||||
client.close()
|
||||
|
||||
Reference in New Issue
Block a user