From 9eb9def85cf5189cf95713559c9d24f7c57c10d1 Mon Sep 17 00:00:00 2001 From: Hector Ros Date: Tue, 20 Jan 2026 18:13:59 +0100 Subject: [PATCH] Add extensive debug logging for K8s client - Log cluster config details - Log HTTPS agent setup - Log detailed error information on pod creation failure - Track applyToHTTPSOptions execution Co-Authored-By: Claude Sonnet 4.5 (1M context) --- src/lib/k8s.ts | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/lib/k8s.ts b/src/lib/k8s.ts index 4ef7320..63e2355 100644 --- a/src/lib/k8s.ts +++ b/src/lib/k8s.ts @@ -21,24 +21,33 @@ export function initK8sClient() { if (inCluster) { k8sConfig.loadFromCluster() + console.log('📦 Loaded K8s config from cluster') // Skip TLS verification when in cluster // This is needed because the cluster uses self-signed certificates const cluster = k8sConfig.getCurrentCluster() + console.log('📦 Current cluster:', cluster) + if (cluster) { cluster.skipTLSVerify = true - console.log('🔓 K8s client configured to skip TLS verification (in-cluster mode)') + console.log('🔓 Set skipTLSVerify = true') } // Create custom HTTPS agent that ignores certificate errors const httpsAgent = new https.Agent({ rejectUnauthorized: false }) + console.log('🔓 Created HTTPS agent with rejectUnauthorized: false') // Apply custom agent to the config - k8sConfig.applyToHTTPSOptions({ - httpsAgent: httpsAgent - } as any) + try { + k8sConfig.applyToHTTPSOptions({ + httpsAgent: httpsAgent + } as any) + console.log('✅ Applied custom HTTPS agent to K8s config') + } catch (applyError: any) { + console.error('❌ Failed to apply HTTPS options:', applyError.message) + } } else { // Load from kubeconfig file const configPath = process.env.K8S_CONFIG_PATH || process.env.KUBECONFIG || '~/.kube/config' @@ -168,14 +177,28 @@ export async function createAgentPod(podName: string, userId: string): Promise