35 lines
1.6 KiB
Python
35 lines
1.6 KiB
Python
import sys
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
def main():
|
|
clusters = [
|
|
("aerodrome", "140.44.4.11"),
|
|
("spaceport", "140.44.4.41")
|
|
]
|
|
for name, host in clusters:
|
|
print(f"=== Configuring Longhorn settings on {name} ({host}) ===")
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
ssh.connect(host, username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
|
|
|
# 1. replica-replenishment-wait-interval -> 300
|
|
cmd1 = "kubectl patch setting.longhorn.io replica-replenishment-wait-interval -n longhorn-system --type=merge -p '{\"value\":\"300\"}'"
|
|
stdin, stdout, stderr = ssh.exec_command(cmd1)
|
|
print("replica-replenishment-wait-interval:", stdout.read().decode().strip(), stderr.read().decode().strip())
|
|
|
|
# 2. node-down-pod-deletion-policy -> delete-deployment-pod
|
|
cmd2 = "kubectl patch setting.longhorn.io node-down-pod-deletion-policy -n longhorn-system --type=merge -p '{\"value\":\"delete-deployment-pod\"}'"
|
|
stdin, stdout, stderr = ssh.exec_command(cmd2)
|
|
print("node-down-pod-deletion-policy:", stdout.read().decode().strip(), stderr.read().decode().strip())
|
|
|
|
# Verify
|
|
stdin, stdout, stderr = ssh.exec_command("kubectl get setting.longhorn.io replica-replenishment-wait-interval node-down-pod-deletion-policy -n longhorn-system -o custom-columns=NAME:.metadata.name,VALUE:.value")
|
|
print("VERIFIED:\n", stdout.read().decode().strip())
|
|
ssh.close()
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|