Skip to content

Commit

Permalink
also run without blinkstick
Browse files Browse the repository at this point in the history
  • Loading branch information
tobru committed Jun 1, 2024
1 parent aab44d6 commit c4bb4ce
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions podstatus/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
kubeconfig_path = config.KUBECONFIG
try:
if kubeconfig_path:
logging.info(f"Loading kubeconfig from {kubeconfig_path}")
k8sconfig.load_kube_config(config_file=kubeconfig_path)
else:
logging.info(f"Loading in-cluster kubeconfig")
k8sconfig.load_incluster_config()

v1 = client.CoreV1Api()
Expand All @@ -38,6 +40,8 @@
# Blinkstick setup
try:
bstick = blinkstick.find_first()
if not bstick:
logging.info("No BlinkStick found")
led_per_pod = 3
except NoBackendError as e:
logging.fatal(f"BlinkStick setup failed: {e}")
Expand Down Expand Up @@ -70,19 +74,18 @@ def watch_pods():
if pod_index not in pod_index_map:
pod_index_map[pod_index] = len(pod_index_map)

color = (
"#008000"
if pod_status == "Running"
else "#ffff00" if pod_status == "Pending" else "#ff0000"
)
set_led_color(pod_index_map[pod_index], color)
if bstick:
color = (
"#008000"
if pod_status == "Running"
else "#ffff00" if pod_status == "Pending" else "#ff0000"
)
set_led_color(pod_index_map[pod_index], color)

yield f'data: {{"name": "{pod_name}", "status": "{pod_status}", "index": "{pod_index}"}}\n\n'


### Routes


@app.route("/")
def index():
return render_template("index.html")
Expand Down

0 comments on commit c4bb4ce

Please sign in to comment.