fix: use KUBERNETES_SERVICE_HOST env var instead of DNS
This commit is contained in:
@@ -48,11 +48,18 @@ func NewLoader(registry *Registry, namespace string) (*Loader, error) {
|
|||||||
pool := x509.NewCertPool()
|
pool := x509.NewCertPool()
|
||||||
pool.AppendCertsFromPEM(caBytes)
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
return &Loader{
|
return &Loader{
|
||||||
registry: registry,
|
registry: registry,
|
||||||
namespace: namespace,
|
namespace: namespace,
|
||||||
token: string(tokenBytes),
|
token: string(tokenBytes),
|
||||||
baseURL: "https://kubernetes.default.svc",
|
baseURL: fmt.Sprintf("https://%s:%s", host, port),
|
||||||
client: &http.Client{
|
client: &http.Client{
|
||||||
Timeout: 30 * time.Second,
|
Timeout: 30 * time.Second,
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
|
|||||||
Reference in New Issue
Block a user