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