feat: add scripts for automating and checking Rancher upgrades via SSH

This commit is contained in:
2026-11-04 23:10:28 -05:00
parent 706fccacb1
commit 1e7935e789
4 changed files with 68 additions and 2 deletions

25
scripts/check_214_pods.py Normal file
View File

@@ -0,0 +1,25 @@
import paramiko
import sys
sys.stdout.reconfigure(encoding='utf-8')
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
client.connect("140.44.4.11", username="root", key_filename=key_path, timeout=15)
stdin, stdout, stderr = client.exec_command("KUBECONFIG=/etc/rancher/k3s/k3s.yaml kubectl -n cattle-system get pods -o wide")
print("=== PODS IN CATTLE-SYSTEM ===")
print(stdout.read().decode('utf-8'))
stdin, stdout, stderr = client.exec_command("KUBECONFIG=/etc/rancher/k3s/k3s.yaml kubectl -n cattle-system rollout status deployment/rancher --timeout=30s")
print("=== ROLLOUT STATUS ===")
print(stdout.read().decode('utf-8'))
print(stderr.read().decode('utf-8'))
stdin, stdout, stderr = client.exec_command("curl -k -I -s https://aerodrome.snarfnet.net | head -n 10")
print("=== ENDPOINT ===")
print(stdout.read().decode('utf-8'))
client.close()

View File

@@ -0,0 +1,14 @@
import paramiko
import sys
sys.stdout.reconfigure(encoding='utf-8')
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
client.connect("140.44.4.11", username="root", key_filename=key_path, timeout=15)
stdin, stdout, stderr = client.exec_command("KUBECONFIG=/etc/rancher/k3s/k3s.yaml helm list -n cattle-system")
print(stdout.read().decode('utf-8'))
client.close()

View File

@@ -61,8 +61,8 @@ sed -i '/kubeVersion:/d' /tmp/rancher-hop/rancher/Chart.yaml
run_cmd(upgrade_cmd)
# 4. Wait for deployment rollout
print("\n--- 4. Waiting for deployment/rancher rollout status (timeout 400s) ---")
run_cmd("kubectl -n cattle-system rollout status deployment/rancher --timeout=400s")
print("\n--- 4. Waiting for deployment/rancher rollout status (timeout 600s) ---")
run_cmd("kubectl -n cattle-system rollout status deployment/rancher --timeout=600s")
# 5. Check cattle-system pods
print("\n--- 5. Checking cattle-system pods ---")

View File

@@ -0,0 +1,27 @@
import paramiko
import sys
sys.stdout.reconfigure(encoding='utf-8')
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
client.connect("140.44.4.11", username="root", key_filename=key_path, timeout=15)
test_cmd = """
rm -rf /tmp/rancher-2153 && mkdir -p /tmp/rancher-2153 && cd /tmp/rancher-2153
KUBECONFIG=/etc/rancher/k3s/k3s.yaml helm pull rancher-stable/rancher --version 2.15.3 --untar
sed -i '/kubeVersion:/d' rancher/Chart.yaml
KUBECONFIG=/etc/rancher/k3s/k3s.yaml helm upgrade rancher ./rancher --namespace cattle-system \
--set hostname=aerodrome.snarfnet.net --set ingress.tls.source=secret --dry-run
"""
stdin, stdout, stderr = client.exec_command(test_cmd)
out = stdout.read().decode('utf-8')
err = stderr.read().decode('utf-8')
print("STDOUT:", out[:400])
print("STDERR:", err)
client.close()