Fix: Use custom HTTPS agent to skip SSL verification
All checks were successful
Build and Push Backend / build (push) Successful in 4s
All checks were successful
Build and Push Backend / build (push) Successful in 4s
skipTLSVerify flag is not respected by @kubernetes/client-node. Solution: Create custom https.Agent with rejectUnauthorized: false Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import * as k8s from '@kubernetes/client-node'
|
import * as k8s from '@kubernetes/client-node'
|
||||||
|
import * as https from 'https'
|
||||||
|
|
||||||
let k8sClient: k8s.CoreV1Api | null = null
|
let k8sClient: k8s.CoreV1Api | null = null
|
||||||
let k8sConfig: k8s.KubeConfig | null = null
|
let k8sConfig: k8s.KubeConfig | null = null
|
||||||
@@ -28,6 +29,16 @@ export function initK8sClient() {
|
|||||||
cluster.skipTLSVerify = true
|
cluster.skipTLSVerify = true
|
||||||
console.log('🔓 K8s client configured to skip TLS verification (in-cluster mode)')
|
console.log('🔓 K8s client configured to skip TLS verification (in-cluster mode)')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create custom HTTPS agent that ignores certificate errors
|
||||||
|
const httpsAgent = new https.Agent({
|
||||||
|
rejectUnauthorized: false
|
||||||
|
})
|
||||||
|
|
||||||
|
// Apply custom agent to the config
|
||||||
|
k8sConfig.applyToHTTPSOptions({
|
||||||
|
httpsAgent: httpsAgent
|
||||||
|
} as any)
|
||||||
} else {
|
} else {
|
||||||
// Load from kubeconfig file
|
// Load from kubeconfig file
|
||||||
const configPath = process.env.K8S_CONFIG_PATH || process.env.KUBECONFIG || '~/.kube/config'
|
const configPath = process.env.K8S_CONFIG_PATH || process.env.KUBECONFIG || '~/.kube/config'
|
||||||
|
|||||||
Reference in New Issue
Block a user