27 lines
937 B
Python
27 lines
937 B
Python
import paramiko
|
|
|
|
def apply_manifest(host, cluster_name, file_path):
|
|
print(f"Applying {file_path} to {cluster_name} ({host})...")
|
|
with open(file_path, 'r') as f:
|
|
manifest_content = f.read()
|
|
|
|
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)
|
|
|
|
stdin, stdout, stderr = ssh.exec_command('k3s kubectl apply -f -')
|
|
stdin.write(manifest_content)
|
|
stdin.channel.shutdown_write()
|
|
|
|
out = stdout.read().decode('utf-8')
|
|
err = stderr.read().decode('utf-8')
|
|
print("Output:")
|
|
print(out)
|
|
if err:
|
|
print("Stderr:", err)
|
|
ssh.close()
|
|
|
|
apply_manifest('140.44.4.11', 'Aerodrome', r'homelab-gitops-repo/manifests/aerodrome/dns/dns-stack.yaml')
|
|
apply_manifest('140.44.4.41', 'Spaceport', r'homelab-gitops-repo/manifests/spaceport/dns/dns-stack.yaml')
|
|
|