From db71919207d47434e9968f31f50d3171205cbdb8 Mon Sep 17 00:00:00 2001 From: Test Date: Mon, 31 Aug 2026 14:49:00 -0700 Subject: [PATCH] fix(llm): make API URL configurable for Kubernetes internal service Issue: Orchestrator pods failing with 'api.riotpiao.com is unreachable' - URL was hardcoded to external hostname - Inside Kubernetes cluster, needs to use internal service DNS Changes: - Make LocalLLMBaseURL read from LOCAL_LLM_BASE_URL env var - Default to 'https://api.riotpiao.com' for external deployments - Update orchestrator-job.yaml to pass internal service: http://api-gateway.api:8080 - Update worker-deployment.yaml to use same internal service URL This allows pods to reach the LLM API via Kubernetes DNS without external network access. --- action/llm/client.go | 15 ++++++++++++--- k8s/git-commit.yaml | 4 ++-- k8s/orchestrator-job.yaml | 2 ++ k8s/worker-deployment.yaml | 6 ++++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/action/llm/client.go b/action/llm/client.go index 94da4e9..b49e495 100644 --- a/action/llm/client.go +++ b/action/llm/client.go @@ -7,16 +7,25 @@ import ( "fmt" "io" "net/http" + "os" "github.com/rockliang/poimen/workflows/statemachine" ) -const ( +var ( // LocalLLMBaseURL is the base URL for the local LLM API (OpenAI-compatible) - // Points to homelab-frontend gateway - LocalLLMBaseURL = "https://api.riotpiao.com" + // Can be overridden via LOCAL_LLM_BASE_URL env var (for Kubernetes internal service) + LocalLLMBaseURL string ) +func init() { + LocalLLMBaseURL = os.Getenv("LOCAL_LLM_BASE_URL") + if LocalLLMBaseURL == "" { + // Default: external hostname (for local dev) + LocalLLMBaseURL = "https://api.riotpiao.com" + } +} + var ( // SupportedModels maps local model names to verify they exist SupportedModels = map[string]bool{ diff --git a/k8s/git-commit.yaml b/k8s/git-commit.yaml index 3aa372b..a4a4b51 100644 --- a/k8s/git-commit.yaml +++ b/k8s/git-commit.yaml @@ -9,6 +9,6 @@ metadata: app.kubernetes.io/name: poimen app.kubernetes.io/component: orchestrator data: - GIT_COMMIT: "166674d" # Updated automatically by CI/CD + GIT_COMMIT: "74a8f2e8" # Updated automatically by CI/CD GIT_BRANCH: "main" - DEPLOYMENT_DATE: "2026-08-30" + DEPLOYMENT_DATE: "2026-08-31" diff --git a/k8s/orchestrator-job.yaml b/k8s/orchestrator-job.yaml index 442f3ce..2363be6 100644 --- a/k8s/orchestrator-job.yaml +++ b/k8s/orchestrator-job.yaml @@ -52,6 +52,8 @@ spec: secretKeyRef: name: poimen-secrets key: ANTHROPIC_API_KEY + - name: LOCAL_LLM_BASE_URL + value: "http://api-gateway.api:8080" resources: requests: memory: "512Mi" diff --git a/k8s/worker-deployment.yaml b/k8s/worker-deployment.yaml index 740b8cb..73df1f5 100644 --- a/k8s/worker-deployment.yaml +++ b/k8s/worker-deployment.yaml @@ -13,8 +13,8 @@ spec: labels: app: poimen-worker annotations: - git-commit: "166674d" # ✅ Updated on each push, triggers rolling restart - deployment-date: "2026-08-30" + git-commit: "74a8f2e8" # ✅ Updated on each push, triggers rolling restart + deployment-date: "2026-08-31" spec: containers: - name: worker @@ -51,6 +51,8 @@ spec: secretKeyRef: name: poimen-secrets key: ANTHROPIC_API_KEY + - name: LOCAL_LLM_BASE_URL + value: "http://api-gateway.api:8080" resources: requests: memory: "512Mi"