39 lines
1.6 KiB
Python
39 lines
1.6 KiB
Python
import paramiko
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
key_path = r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet'
|
|
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
ssh.connect("140.44.4.41", username="root", key_filename=key_path, timeout=10)
|
|
|
|
with open(r"C:\Users\Snarf\OneDrive\Desktop\code\SnarfCode\homelab-gitops-repo\manifests\spaceport\semaphore\semaphore.yaml", "r", encoding="utf-8") as f:
|
|
manifest_content = f.read()
|
|
|
|
print("Applying with --force-conflicts=true...")
|
|
stdin, stdout, stderr = ssh.exec_command("k3s kubectl apply -f - --server-side=true --force-conflicts=true")
|
|
stdin.write(manifest_content)
|
|
stdin.channel.shutdown_write()
|
|
print("Apply stdout:", stdout.read().decode())
|
|
print("Apply stderr:", stderr.read().decode())
|
|
|
|
print("Refreshing ArgoCD Application...")
|
|
# Check if argocd CLI or patch annotation
|
|
stdin, stdout, stderr = ssh.exec_command("k3s kubectl annotate application spaceport-semaphore -n infrastructure argocd.argoproj.io/refresh=hard --overwrite")
|
|
print(stdout.read().decode())
|
|
|
|
print("Waiting for deployment rollout...")
|
|
stdin, stdout, stderr = ssh.exec_command("k3s kubectl rollout status deployment/semaphore -n infrastructure --timeout=60s")
|
|
print(stdout.read().decode())
|
|
|
|
stdin, stdout, stderr = ssh.exec_command("k3s kubectl get pods -n infrastructure -l app.kubernetes.io/name=semaphore -o jsonpath='{.items[0].metadata.name}'")
|
|
pod = stdout.read().decode().strip()
|
|
print(f"Active pod: {pod}")
|
|
|
|
stdin, stdout, stderr = ssh.exec_command(f"k3s kubectl exec -n infrastructure {pod} -- env | grep SEMAPHORE_OIDC_PROVIDERS")
|
|
print("Live env:\n", stdout.read().decode())
|
|
|
|
ssh.close()
|
|
|