fix: verify dev k3s health via service proxy
This commit is contained in:
@@ -1677,18 +1677,18 @@ async function directHttpJson(url: string, timeoutMs: number): Promise<unknown>
|
||||
|
||||
function devK3sServiceHealthScript(service: UniDeskMicroserviceConfig): string {
|
||||
const namespace = k8sNamespaceForService(service);
|
||||
const deployment = service.repository.composeService;
|
||||
const serviceName = service.repository.composeService;
|
||||
const path = service.backend.healthPath;
|
||||
const port = service.backend.nodePort;
|
||||
return [
|
||||
"set -euo pipefail",
|
||||
`namespace=${shellQuote(namespace)}`,
|
||||
`deployment=${shellQuote(deployment)}`,
|
||||
`service_name=${shellQuote(serviceName)}`,
|
||||
`path=${shellQuote(path)}`,
|
||||
`port=${shellQuote(String(port))}`,
|
||||
`pod=$(KUBECONFIG=${shellQuote(k8sKubeconfig)} kubectl -n "$namespace" get pod -l app.kubernetes.io/instance="$deployment",unidesk.ai/deploy-service-id=${shellQuote(service.id)},unidesk.ai/environment=dev -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || true)`,
|
||||
"if [ -z \"$pod\" ]; then echo '{\"ok\":false,\"error\":\"dev deployment pod not found\"}'; exit 0; fi",
|
||||
`KUBECONFIG=${shellQuote(k8sKubeconfig)} kubectl -n "$namespace" exec "$pod" -- wget -q -T 5 -O - "http://127.0.0.1:$port$path"`,
|
||||
"case \"$path\" in /*) ;; *) path=\"/$path\" ;; esac",
|
||||
"proxy_path=\"/api/v1/namespaces/$namespace/services/http:$service_name:$port/proxy$path\"",
|
||||
`KUBECONFIG=${shellQuote(k8sKubeconfig)} kubectl get --raw "$proxy_path"`,
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user