diff --git a/scripts/check_chart_versions.py b/scripts/check_chart_versions.py index 7d94e1a..8da006a 100644 --- a/scripts/check_chart_versions.py +++ b/scripts/check_chart_versions.py @@ -1,19 +1,13 @@ import paramiko +import sys -def check_catalog_versions(ip, cluster_name): - print(f"\n=======================================================") - print(f"=== {cluster_name} AVAILABLE CHART VERSIONS ===") - print(f"=======================================================") - ssh = paramiko.SSHClient() - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - ssh.connect(ip, username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10) - - # We can inspect the Rancher catalog charts - cmd = "kubectl get charts.catalog.cattle.io -A -o custom-columns=REPO:.metadata.namespace,CHART:.metadata.name | head -n 30" - _, out, _ = ssh.exec_command(cmd) - print(out.read().decode()) - ssh.close() +sys.stdout.reconfigure(encoding='utf-8') -check_catalog_versions('140.44.4.11', 'AERODROME') -check_catalog_versions('140.44.4.41', 'SPACEPORT') +client = paramiko.SSHClient() +client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) +key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet" +client.connect("140.44.4.11", username="root", key_filename=key_path, timeout=15) +stdin, stdout, stderr = client.exec_command("KUBECONFIG=/etc/rancher/k3s/k3s.yaml helm search repo rancher-stable/rancher --versions > /tmp/rancher_versions.txt && head -n 30 /tmp/rancher_versions.txt") +print(stdout.read().decode('utf-8')) +client.close() diff --git a/scripts/check_rancher_helm_versions.py b/scripts/check_rancher_helm_versions.py new file mode 100644 index 0000000..60a076b --- /dev/null +++ b/scripts/check_rancher_helm_versions.py @@ -0,0 +1,20 @@ +import paramiko +import sys + +sys.stdout.reconfigure(encoding='utf-8') + +ssh = paramiko.SSHClient() +ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) +ssh.connect('140.44.4.11', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10) + +def run(cmd): + print(f"=== {cmd} ===") + _, out, err = ssh.exec_command(cmd) + res = out.read().decode('utf-8', errors='replace').strip() + if res: + print(res) + +run("KUBECONFIG=/etc/rancher/k3s/k3s.yaml helm repo update rancher-stable") +run("KUBECONFIG=/etc/rancher/k3s/k3s.yaml helm search repo rancher-stable/rancher --versions | head -n 35") + +ssh.close() diff --git a/scripts/check_rancher_versions.py b/scripts/check_rancher_versions.py new file mode 100644 index 0000000..532ed58 --- /dev/null +++ b/scripts/check_rancher_versions.py @@ -0,0 +1,14 @@ +import paramiko +import sys + +sys.stdout.reconfigure(encoding='utf-8') + +client = paramiko.SSHClient() +client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) +key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet" + +client.connect("140.44.4.11", username="root", key_filename=key_path, timeout=15) +stdin, stdout, stderr = client.exec_command("KUBECONFIG=/etc/rancher/k3s/k3s.yaml helm search repo rancher-stable/rancher --versions | head -n 35") +print(stdout.read().decode('utf-8')) +client.close() + diff --git a/scripts/check_tls_rancher.py b/scripts/check_tls_rancher.py new file mode 100644 index 0000000..45de6ff --- /dev/null +++ b/scripts/check_tls_rancher.py @@ -0,0 +1,15 @@ +import paramiko +import sys + +sys.stdout.reconfigure(encoding='utf-8') + +client = paramiko.SSHClient() +client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) +key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet" + +client.connect("140.44.4.11", username="root", key_filename=key_path, timeout=15) +stdin, stdout, stderr = client.exec_command("KUBECONFIG=/etc/rancher/k3s/k3s.yaml kubectl -n cattle-system get secret tls-rancher-ingress") +print(stdout.read().decode('utf-8')) +print(stderr.read().decode('utf-8')) +client.close() + diff --git a/scripts/find_rancher_series.py b/scripts/find_rancher_series.py new file mode 100644 index 0000000..1aa8fb4 --- /dev/null +++ b/scripts/find_rancher_series.py @@ -0,0 +1,27 @@ +import urllib.request +import json +import re + +releases = {} + +for page in range(1, 20): + url = f"https://api.github.com/repos/rancher/rancher/tags?per_page=100&page={page}" + req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'}) + try: + data = json.loads(urllib.request.urlopen(req).read().decode()) + except: + break + if not data: + break + for item in data: + name = item['name'] + m = re.match(r"^v(2\.\d+)\.(\d+)$", name) + if m: + series = m.group(1) + patch = int(m.group(2)) + if series not in releases or patch > releases[series]: + releases[series] = patch + +for s in sorted(releases.keys(), key=lambda x: [int(p) for p in x.split('.')]): + print(f"Series v{s}: latest patch is v{s}.{releases[s]}") + diff --git a/scripts/get_rancher_values.py b/scripts/get_rancher_values.py new file mode 100644 index 0000000..203078b --- /dev/null +++ b/scripts/get_rancher_values.py @@ -0,0 +1,15 @@ +import paramiko +import sys + +sys.stdout.reconfigure(encoding='utf-8') + +client = paramiko.SSHClient() +client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) +key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet" + +client.connect("140.44.4.11", username="root", key_filename=key_path, timeout=15) +stdin, stdout, stderr = client.exec_command("KUBECONFIG=/etc/rancher/k3s/k3s.yaml helm get values rancher -n cattle-system") +print("=== CURRENT RANCHER VALUES ===") +print(stdout.read().decode('utf-8')) +client.close() + diff --git a/scripts/inspect_rancher_helm.py b/scripts/inspect_rancher_helm.py new file mode 100644 index 0000000..ba3a1be --- /dev/null +++ b/scripts/inspect_rancher_helm.py @@ -0,0 +1,21 @@ +import paramiko +import base64 +import gzip +import json + +ssh = paramiko.SSHClient() +ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) +ssh.connect('140.44.4.11', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10) + +_, out, _ = ssh.exec_command('kubectl get secret -n cattle-system sh.helm.release.v1.rancher.v1 -o jsonpath="{.data.release}"') +raw = out.read().decode().strip() +if raw: + data = base64.b64decode(raw) + data = base64.b64decode(data) # helm encodes twice + decomp = gzip.decompress(data) + rel = json.loads(decomp) + print("Chart:", rel.get('chart', {}).get('metadata', {}).get('version')) + print("Values:", json.dumps(rel.get('config', {}), indent=2)) + +ssh.close() + diff --git a/scripts/inspect_rancher_installation.py b/scripts/inspect_rancher_installation.py new file mode 100644 index 0000000..ae7c05a --- /dev/null +++ b/scripts/inspect_rancher_installation.py @@ -0,0 +1,26 @@ +import paramiko + +ssh = paramiko.SSHClient() +ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) +ssh.connect('140.44.4.11', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10) + +def run(cmd): + print(f"\n=== {cmd} ===") + _, out, err = ssh.exec_command(cmd) + res = out.read().decode('utf-8', errors='replace').strip() + if res: + print(res) + e = err.read().decode('utf-8', errors='replace').strip() + if e: + print("ERR:", e) + +run("kubectl get deploy,sts,ds -n cattle-system -o wide") +run("kubectl get pods -n cattle-system -o wide") +run("kubectl get deploy -n cattle-system rancher -o yaml | grep -E 'image:'") +run("kubectl get secrets -n cattle-system | grep -i helm") +run("kubectl get helmcharts,helmchartconfigs -A | grep -i rancher") +run("kubectl get ns | grep -E 'cert-manager|cattle'") +run("kubectl get pods -n cert-manager 2>/dev/null || true") + +ssh.close() + diff --git a/scripts/rancher_status.py b/scripts/rancher_status.py new file mode 100644 index 0000000..869a6d5 --- /dev/null +++ b/scripts/rancher_status.py @@ -0,0 +1,34 @@ +import paramiko +import sys + +sys.stdout.reconfigure(encoding='utf-8') + +client = paramiko.SSHClient() +client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) +key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet" + +try: + client.connect("140.44.4.11", username="root", key_filename=key_path, timeout=10) + print("=== Connected to Aerodrome (140.44.4.11) ===") + + cmds = [ + "kubectl -n cattle-system get pods -o wide", + "helm list -n cattle-system", + "helm repo list", + "k3s etcd-snapshot list" + ] + + for cmd in cmds: + print(f"\n--- Running: {cmd} ---") + stdin, stdout, stderr = client.exec_command(f"KUBECONFIG=/etc/rancher/k3s/k3s.yaml {cmd}") + out = stdout.read().decode('utf-8') + err = stderr.read().decode('utf-8') + if out: + print(out.strip()) + if err: + print(f"ERR: {err.strip()}") + + client.close() +except Exception as e: + print(f"Error: {e}") + diff --git a/scripts/test_etcd_helm.py b/scripts/test_etcd_helm.py new file mode 100644 index 0000000..4345729 --- /dev/null +++ b/scripts/test_etcd_helm.py @@ -0,0 +1,29 @@ +import paramiko +import sys + +sys.stdout.reconfigure(encoding='utf-8') + +client = paramiko.SSHClient() +client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) +key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet" + +def run_remote(cmd): + client.connect("140.44.4.11", username="root", key_filename=key_path, timeout=15) + stdin, stdout, stderr = client.exec_command(cmd) + out = stdout.read().decode('utf-8') + err = stderr.read().decode('utf-8') + client.close() + return out, err + +out, err = run_remote("k3s etcd-snapshot list") +print("=== ETCD SNAPSHOTS ===") +print(out) +if err: + print("ERR:", err) + +out, err = run_remote("KUBECONFIG=/etc/rancher/k3s/k3s.yaml helm repo list") +print("=== HELM REPOS ===") +print(out) +if err: + print("ERR:", err) +