Compare commits
No commits in common. "d49ba1221a402736f9d198daf3e7ea68808a2b6c" and "9e0d7d0726ca0bbf00a74b809c9c477f24a8cdec" have entirely different histories.
d49ba1221a
...
9e0d7d0726
30
app.py
30
app.py
|
|
@ -1,20 +1,8 @@
|
|||
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():
|
||||
|
|
@ -25,16 +13,10 @@ def get_k8s_client():
|
|||
config.load_kube_config()
|
||||
except Exception as e:
|
||||
print(f"Error loading kubeconfig: {e}")
|
||||
loaded = False
|
||||
for fallback_path in ["/home/nonroot/.kube/config", "/root/.kube/config"]:
|
||||
# Try a fallback if they mounted to /root/.kube/config but KUBECONFIG is wrong
|
||||
try:
|
||||
if os.path.exists(fallback_path):
|
||||
config.load_kube_config(config_file=fallback_path)
|
||||
loaded = True
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
if not loaded:
|
||||
config.load_kube_config(config_file="/root/.kube/config")
|
||||
except Exception as e2:
|
||||
raise RuntimeError(f"Failed to load kubeconfig. Make sure the file exists and is accessible. Error: {e}")
|
||||
return client.CoreV1Api(), client.CustomObjectsApi()
|
||||
|
||||
|
|
@ -175,13 +157,9 @@ 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', version=get_version())
|
||||
return render_template('index.html')
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=5000)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ services:
|
|||
ports:
|
||||
- "5000:5000"
|
||||
environment:
|
||||
- KUBECONFIG=/home/nonroot/.kube/config
|
||||
- KUBECONFIG=/root/.kube/config
|
||||
volumes:
|
||||
- ${KUBECONFIG:-~/.kube/config}:/home/nonroot/.kube/config:ro
|
||||
- ${KUBECONFIG:-~/.kube/config}:/root/.kube/config:ro
|
||||
restart: unless-stopped
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 159 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB |
|
|
@ -64,12 +64,6 @@ body {
|
|||
color: var(--accent);
|
||||
}
|
||||
|
||||
.logo-icon {
|
||||
height: 32px;
|
||||
width: auto;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.logo h1 {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
|
|
@ -241,19 +235,6 @@ body {
|
|||
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 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@
|
|||
<div class="app-container">
|
||||
<header class="glass-panel header">
|
||||
<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>
|
||||
</div>
|
||||
<div class="controls">
|
||||
|
|
@ -68,11 +72,6 @@
|
|||
<div class="legend-divider"></div>
|
||||
<div class="legend-note">📐 <strong>Tower Height</strong> = Resource Usage</div>
|
||||
</div>
|
||||
|
||||
<!-- Version Footer Overlay -->
|
||||
<div class="version-overlay glass-panel">
|
||||
<span>v: {{ version }}</span>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
[metadata]
|
||||
version = 0.6
|
||||
version = 0.5
|
||||
|
|
|
|||
Loading…
Reference in New Issue