feat: add homelab deployment configs, documentation, and automation scripts
This commit is contained in:
43
scripts/upload_topology_to_homepage.py
Normal file
43
scripts/upload_topology_to_homepage.py
Normal file
@@ -0,0 +1,43 @@
|
||||
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)
|
||||
|
||||
def run(cmd):
|
||||
_, o, e = c.exec_command(cmd)
|
||||
out = o.read().decode().strip()
|
||||
err = e.read().decode().strip()
|
||||
if err:
|
||||
print('[stderr]', err)
|
||||
return out
|
||||
|
||||
with open('docs/snarfnet_homelab_topology.html', 'r', encoding='utf-8') as f:
|
||||
html_content = f.read()
|
||||
|
||||
with open('docs/snarfnet_homelab_topology.png', 'rb') as f:
|
||||
png_content = f.read()
|
||||
|
||||
# Send html
|
||||
stdin, stdout, stderr = c.exec_command('cat > /tmp/topology.html')
|
||||
stdin.write(html_content)
|
||||
stdin.close()
|
||||
stdout.read()
|
||||
|
||||
# Send png
|
||||
stdin, stdout, stderr = c.exec_command('cat > /tmp/topology.png')
|
||||
stdin.write(png_content)
|
||||
stdin.close()
|
||||
stdout.read()
|
||||
|
||||
pod = run("kubectl get pod -n infrastructure -l app.kubernetes.io/name=homepage-2-1744068158 -o jsonpath='{.items[0].metadata.name}'")
|
||||
print(f'Target Pod: {pod}')
|
||||
|
||||
print(run(f'kubectl cp /tmp/topology.png infrastructure/{pod}:/app/public/topology.png'))
|
||||
print(run(f'kubectl cp /tmp/topology.html infrastructure/{pod}:/app/public/topology.html'))
|
||||
|
||||
print('Files in /app/public:')
|
||||
print(run(f'kubectl exec -n infrastructure {pod} -- ls -lh /app/public/topology*'))
|
||||
|
||||
c.close()
|
||||
print('Topology updated on Homepage successfully!')
|
||||
Reference in New Issue
Block a user