Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Kubelet race not setting correct pod env (KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT) #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/kubeconfig/getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ func (g *getter) Get(configPath string) (*rest.Config, error) {
// If no explicit location, try the in-cluster config.
_, okHost := g.lookupEnv("KUBERNETES_SERVICE_HOST")
_, okPort := g.lookupEnv("KUBERNETES_SERVICE_PORT")
// Work around https://github.com/kubernetes/kubernetes/issues/40973
if !okHost{
addrs, err := net.LookupHost("kubernetes.default.svc")
if err == nil {
os.Setenv("KUBERNETES_SERVICE_HOST", addrs[0])
okHost := true
if !okPort{
os.Setenv("KUBERNETES_SERVICE_PORT", "443")
okPort := true
}
}
}
if okHost && okPort {
c, err := g.inClusterConfig()
if err == nil {
Expand Down