fix: route k8s API through nginx proxy, drop CiliumNetworkPolicy
CI / Vet, test, build (push) Successful in 2m4s
CI / Build and push image (push) Successful in 42s

This commit is contained in:
Admin Bot
2026-08-26 16:24:43 -07:00
parent d51b99add3
commit 977058d0b0
5 changed files with 102 additions and 24 deletions
+9 -8
View File
@@ -48,22 +48,23 @@ func NewLoader(registry *Registry, namespace string) (*Loader, error) {
pool := x509.NewCertPool()
pool.AppendCertsFromPEM(caBytes)
// Use env vars injected by kubelet — no DNS dependency
host := os.Getenv("KUBERNETES_SERVICE_HOST")
port := os.Getenv("KUBERNETES_SERVICE_PORT")
if host == "" || port == "" {
return nil, fmt.Errorf("KUBERNETES_SERVICE_HOST/PORT not set")
// Use kube-api-proxy (nginx) in the same namespace to reach the API server.
// This avoids needing direct egress to the API server ClusterIP which
// standard NetworkPolicy can't allow through Cilium.
proxyHost := os.Getenv("KUBE_API_PROXY_URL")
if proxyHost == "" {
proxyHost = "https://kube-api-proxy.api.svc.cluster.local:8443"
}
return &Loader{
registry: registry,
namespace: namespace,
token: string(tokenBytes),
baseURL: fmt.Sprintf("https://%s:%s", host, port),
baseURL: proxyHost,
client: &http.Client{
Timeout: 30 * time.Second,
Timeout: 10 * time.Second,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{RootCAs: pool},
TLSClientConfig: &tls.Config{RootCAs: pool, InsecureSkipVerify: true},
},
},
stopChan: make(chan struct{}),