33 lines
1.4 KiB
Python
33 lines
1.4 KiB
Python
import paramiko
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect('140.44.4.41', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
|
|
|
_, o, _ = c.exec_command('kubectl get pod -n infrastructure -l app.kubernetes.io/name=homepage-2-1744068158 -o jsonpath="{.items[0].metadata.name}"')
|
|
pod = o.read().decode().strip()
|
|
|
|
_, o, e = c.exec_command(f'kubectl exec -n infrastructure {pod} -- ls -la /app/public')
|
|
print("ls -la /app/public:\n", o.read().decode().strip())
|
|
|
|
# Test copying a file directly into the pod using cat
|
|
_, o, _ = c.exec_command(f'kubectl exec -i -n infrastructure {pod} -- sh -c "cat > /app/public/test.txt"')
|
|
# Wait, let's test if cat > /app/public/ works
|
|
stdin, stdout, stderr = c.exec_command(f'kubectl exec -i -n infrastructure {pod} -- sh -c "cat > /app/public/topology.html"')
|
|
with open('docs/snarfnet_homelab_topology.html', 'r', encoding='utf-8') as f:
|
|
stdin.write(f.read())
|
|
stdin.close()
|
|
stdout.read()
|
|
|
|
stdin, stdout, stderr = c.exec_command(f'kubectl exec -i -n infrastructure {pod} -- sh -c "cat > /app/public/topology.png"')
|
|
with open('docs/snarfnet_homelab_topology.png', 'rb') as f:
|
|
stdin.write(f.read())
|
|
stdin.close()
|
|
stdout.read()
|
|
|
|
_, o, e = c.exec_command(f'kubectl exec -n infrastructure {pod} -- ls -lh /app/public/topology*')
|
|
print("After streaming directly:\n", o.read().decode().strip())
|
|
print("Stderr:\n", e.read().decode().strip())
|
|
|
|
c.close()
|