Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #168 from sevennt/fix/ek8s-ns
Browse files Browse the repository at this point in the history
fix: default namespace
  • Loading branch information
sevennt committed Dec 23, 2021
2 parents 4ad98a8 + 976adee commit 731d898
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ek8s/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func DefaultConfig() *Config {
return &Config{
Addr: inClusterAddr(),
Token: inClusterToken(),
Namespaces: []string{"default"},
Namespaces: []string{inClusterNamespace()},
TLSClientConfigInsecure: true,
}
}
Expand Down Expand Up @@ -55,3 +55,11 @@ func inClusterToken() string {
}
return strings.TrimSpace(string(t))
}

func inClusterNamespace() string {
t, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
if err != nil {
return ""
}
return strings.TrimSpace(string(t))
}

0 comments on commit 731d898

Please sign in to comment.