diff --git a/app.py b/app.py index 5ca041d..fc7c0e3 100644 --- a/app.py +++ b/app.py @@ -1,8 +1,20 @@ import os +import configparser from flask import Flask, jsonify, render_template from kubernetes import client, config from kubernetes.client.rest import ApiException +def get_version(): + try: + ini_path = os.path.join(os.path.dirname(__file__), 'version.ini') + if os.path.exists(ini_path): + parser = configparser.ConfigParser() + parser.read(ini_path) + return parser.get('metadata', 'version', fallback='0.5') + except Exception as e: + print(f"Error reading version.ini: {e}") + return '0.5' + app = Flask(__name__) def get_k8s_client(): @@ -13,10 +25,16 @@ def get_k8s_client(): config.load_kube_config() except Exception as e: print(f"Error loading kubeconfig: {e}") - # Try a fallback if they mounted to /root/.kube/config but KUBECONFIG is wrong - try: - config.load_kube_config(config_file="/root/.kube/config") - except Exception as e2: + loaded = False + for fallback_path in ["/home/nonroot/.kube/config", "/root/.kube/config"]: + try: + if os.path.exists(fallback_path): + config.load_kube_config(config_file=fallback_path) + loaded = True + break + except Exception: + pass + if not loaded: raise RuntimeError(f"Failed to load kubeconfig. Make sure the file exists and is accessible. Error: {e}") return client.CoreV1Api(), client.CustomObjectsApi() @@ -157,9 +175,13 @@ def cluster_data(): traceback.print_exc() return jsonify({"error": str(e)}), 500 +@app.route('/api/version') +def version_route(): + return jsonify({"version": get_version()}) + @app.route('/') def index(): - return render_template('index.html') + return render_template('index.html', version=get_version()) if __name__ == '__main__': app.run(host='0.0.0.0', port=5000) diff --git a/docker-compose.yml b/docker-compose.yml index 37309fe..71dfba1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: ports: - "5000:5000" environment: - - KUBECONFIG=/root/.kube/config + - KUBECONFIG=/home/nonroot/.kube/config volumes: - - ${KUBECONFIG:-~/.kube/config}:/root/.kube/config:ro + - ${KUBECONFIG:-~/.kube/config}:/home/nonroot/.kube/config:ro restart: unless-stopped diff --git a/static/k8spulselogo-lg.png b/static/k8spulselogo-lg.png new file mode 100644 index 0000000..1b1071e Binary files /dev/null and b/static/k8spulselogo-lg.png differ diff --git a/static/k8spulselogo-sm.png b/static/k8spulselogo-sm.png new file mode 100644 index 0000000..45f5822 Binary files /dev/null and b/static/k8spulselogo-sm.png differ diff --git a/static/style.css b/static/style.css index 32fa1a1..a4de4ff 100644 --- a/static/style.css +++ b/static/style.css @@ -64,6 +64,12 @@ body { color: var(--accent); } +.logo-icon { + height: 32px; + width: auto; + object-fit: contain; +} + .logo h1 { font-size: 1.25rem; font-weight: 700; @@ -224,7 +230,7 @@ body { .legend-panel { position: absolute; - bottom: 1rem; + bottom: 3.25rem; right: 1rem; display: flex; flex-direction: column; @@ -235,6 +241,19 @@ body { pointer-events: none; } +.version-overlay { + position: absolute; + bottom: 1rem; + right: 1rem; + padding: 0.35rem 0.75rem; + font-size: 0.75rem; + font-weight: 600; + color: var(--text-muted); + z-index: 10; + pointer-events: none; + letter-spacing: 0.05em; +} + .legend-item { display: flex; align-items: center; diff --git a/templates/index.html b/templates/index.html index c65772d..2b8b4ca 100644 --- a/templates/index.html +++ b/templates/index.html @@ -18,11 +18,7 @@