From be10268c03de830f97dbe952b4e8bf3e00b50837 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 5 Nov 2026 10:13:36 +0900 Subject: [PATCH] refac --- README.md | 34 ++++++++++++++++++++++++++++++++ operator/handler.py | 3 +++ terminals/backends/kubernetes.py | 3 +++ 3 files changed, 40 insertions(+) diff --git a/README.md b/README.md index 35bd6e9..aa5949e 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,40 @@ policy `podTemplate` field and native Kubernetes volumes instead: Read-only mounts prevent writes through that mount, but they are not a security boundary if terminal containers are privileged or can access the Docker socket. +### Kubernetes health probes + +Both Kubernetes backends accept probe overrides in the policy's `podTemplate`. +Each supplied probe replaces the default, so include its check (such as +`httpGet`) as well as timing settings. For slower hardware: + +```json +{ + "podTemplate": { + "spec": { + "containers": [{ + "name": "open-terminal", + "readinessProbe": { + "httpGet": {"path": "/health", "port": 8000}, + "initialDelaySeconds": 15, + "periodSeconds": 10, + "timeoutSeconds": 5, + "failureThreshold": 6 + }, + "livenessProbe": { + "httpGet": {"path": "/health", "port": 8000}, + "initialDelaySeconds": 60, + "periodSeconds": 15, + "timeoutSeconds": 5, + "failureThreshold": 6 + } + }] + } + } +``` + +Omitted probes keep their existing defaults. Refresh existing terminals to apply +the updated policy on their next access. + ### Policy lifecycle Policies define what gets provisioned. Policy lifecycle config defines ongoing maintenance for that policy, such as scheduled resets of persisted terminal files. Due resets refresh matching terminals even when they are still running, so long-lived browser sessions do not block scheduled cleanup. diff --git a/operator/handler.py b/operator/handler.py index 84041b6..894153f 100644 --- a/operator/handler.py +++ b/operator/handler.py @@ -211,6 +211,9 @@ def _apply_pod_template(pod_manifest: dict, pod_template: dict | None) -> dict: {}, ) generated_container = generated_spec["containers"][0] + for field in ("readinessProbe", "livenessProbe"): + if field in template_container: + container[field] = template_container[field] for field in ("env", "ports", "volumeMounts"): container[field] = _merge_by_name( template_container.get(field), generated_container.get(field) diff --git a/terminals/backends/kubernetes.py b/terminals/backends/kubernetes.py index 5ad876b..ff40f56 100644 --- a/terminals/backends/kubernetes.py +++ b/terminals/backends/kubernetes.py @@ -153,6 +153,9 @@ def _apply_pod_template(pod_manifest: dict, pod_template: dict | None) -> dict: {}, ) generated_container = generated_spec["containers"][0] + for field in ("readinessProbe", "livenessProbe"): + if field in template_container: + container[field] = template_container[field] for field in ("env", "ports", "volumeMounts"): container[field] = _merge_by_name( template_container.get(field), generated_container.get(field)