37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
import paramiko
|
|
import time
|
|
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
ssh.connect('140.44.4.11', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
|
|
|
def run(cmd):
|
|
print(f"=== {cmd} ===")
|
|
_, out, err = ssh.exec_command(cmd)
|
|
res = out.read().decode().strip()
|
|
if res:
|
|
print(res)
|
|
e = err.read().decode().strip()
|
|
if e:
|
|
print("ERR:", e)
|
|
|
|
# 1. Update strategy to Recreate
|
|
run("""kubectl patch deployment uptime-kuma-2-1756668961 -n monitoring --type='json' -p='[{"op": "replace", "path": "/spec/strategy", "value": {"type": "Recreate"}}]'""")
|
|
|
|
# 2. Scale down to 0 to release all locks cleanly
|
|
print("[*] Scaling down to 0 to release all volume locks...")
|
|
run("kubectl scale deployment uptime-kuma-2-1756668961 -n monitoring --replicas=0")
|
|
run("kubectl wait --for=delete pod -l app.kubernetes.io/name=uptime-kuma -n monitoring --timeout=60s || true")
|
|
|
|
# 3. Set image to 2.5.9
|
|
run("kubectl set image deployment/uptime-kuma-2-1756668961 uptime-kuma=louislam/uptime-kuma:2.5.9 -n monitoring")
|
|
|
|
# 4. Scale up to 1
|
|
print("[*] Scaling up to 1...")
|
|
run("kubectl scale deployment uptime-kuma-2-1756668961 -n monitoring --replicas=1")
|
|
run("kubectl rollout status deployment/uptime-kuma-2-1756668961 -n monitoring --timeout=120s")
|
|
run("kubectl get pods -n monitoring -l app.kubernetes.io/name=uptime-kuma -o wide")
|
|
|
|
ssh.close()
|
|
|