hostinfo: add EnvType for Kubernetes

Signed-off-by: Maisem Ali <[email protected]>
(cherry picked from commit 2662a1c98c)
This commit is contained in:
Maisem Ali committed 2021-10-14 23:03:26 -04:00
1 parent d0c3c14a58
commit ffaa572266
1 file changed
+11
+11
View File
@@ -82,6 +82,7 @@ const (
AzureAppService = EnvType("az")
AWSFargate = EnvType("fg")
FlyDotIo = EnvType("fly")
Kubernetes = EnvType("k8s")
)
var envType atomic.Value // of EnvType
@@ -136,6 +137,9 @@ func getEnvType() EnvType {
if inFlyDotIo() {
return FlyDotIo
}
if inKubernetes() {
return Kubernetes
}
return ""
}
@@ -212,3 +216,10 @@ func inFlyDotIo() bool {
}
return false
}
func inKubernetes() bool {
if os.Getenv("KUBERNETES_SERVICE_HOST") != "" && os.Getenv("KUBERNETES_SERVICE_PORT") != "" {
return true
}
return false
}