Compare commits

..

No commits in common. "d49ba1221a402736f9d198daf3e7ea68808a2b6c" and "9e0d7d0726ca0bbf00a74b809c9c477f24a8cdec" have entirely different histories.

7 changed files with 13 additions and 55 deletions

32
app.py
View File

@ -1,20 +1,8 @@
import os import os
import configparser
from flask import Flask, jsonify, render_template from flask import Flask, jsonify, render_template
from kubernetes import client, config from kubernetes import client, config
from kubernetes.client.rest import ApiException 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__) app = Flask(__name__)
def get_k8s_client(): def get_k8s_client():
@ -25,16 +13,10 @@ def get_k8s_client():
config.load_kube_config() config.load_kube_config()
except Exception as e: except Exception as e:
print(f"Error loading kubeconfig: {e}") print(f"Error loading kubeconfig: {e}")
loaded = False # Try a fallback if they mounted to /root/.kube/config but KUBECONFIG is wrong
for fallback_path in ["/home/nonroot/.kube/config", "/root/.kube/config"]: try:
try: config.load_kube_config(config_file="/root/.kube/config")
if os.path.exists(fallback_path): except Exception as e2:
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}") raise RuntimeError(f"Failed to load kubeconfig. Make sure the file exists and is accessible. Error: {e}")
return client.CoreV1Api(), client.CustomObjectsApi() return client.CoreV1Api(), client.CustomObjectsApi()
@ -175,13 +157,9 @@ def cluster_data():
traceback.print_exc() traceback.print_exc()
return jsonify({"error": str(e)}), 500 return jsonify({"error": str(e)}), 500
@app.route('/api/version')
def version_route():
return jsonify({"version": get_version()})
@app.route('/') @app.route('/')
def index(): def index():
return render_template('index.html', version=get_version()) return render_template('index.html')
if __name__ == '__main__': if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000) app.run(host='0.0.0.0', port=5000)

View File

@ -7,7 +7,7 @@ services:
ports: ports:
- "5000:5000" - "5000:5000"
environment: environment:
- KUBECONFIG=/home/nonroot/.kube/config - KUBECONFIG=/root/.kube/config
volumes: volumes:
- ${KUBECONFIG:-~/.kube/config}:/home/nonroot/.kube/config:ro - ${KUBECONFIG:-~/.kube/config}:/root/.kube/config:ro
restart: unless-stopped restart: unless-stopped

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@ -64,12 +64,6 @@ body {
color: var(--accent); color: var(--accent);
} }
.logo-icon {
height: 32px;
width: auto;
object-fit: contain;
}
.logo h1 { .logo h1 {
font-size: 1.25rem; font-size: 1.25rem;
font-weight: 700; font-weight: 700;
@ -241,19 +235,6 @@ body {
pointer-events: none; pointer-events: none;
} }
.version-overlay {
position: absolute;
bottom: 1rem;
left: 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 { .legend-item {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -18,7 +18,11 @@
<div class="app-container"> <div class="app-container">
<header class="glass-panel header"> <header class="glass-panel header">
<div class="logo"> <div class="logo">
<img src="/static/k8spulselogo-sm.png" alt="K8s Pulse Logo" class="logo-icon"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 2L2 7L12 12L22 7L12 2Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M2 17L12 22L22 17" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M2 12L12 17L22 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<h1>K8s Pulse <span class="badge-3d">3D</span></h1> <h1>K8s Pulse <span class="badge-3d">3D</span></h1>
</div> </div>
<div class="controls"> <div class="controls">
@ -68,11 +72,6 @@
<div class="legend-divider"></div> <div class="legend-divider"></div>
<div class="legend-note">📐 <strong>Tower Height</strong> = Resource Usage</div> <div class="legend-note">📐 <strong>Tower Height</strong> = Resource Usage</div>
</div> </div>
<!-- Version Footer Overlay -->
<div class="version-overlay glass-panel">
<span>v: {{ version }}</span>
</div>
</main> </main>
</div> </div>

View File

@ -1,2 +1,2 @@
[metadata] [metadata]
version = 0.6 version = 0.5