From 2662a1c98c1c4c67d9abeb0baddc352d74cd33ef Mon Sep 17 00:00:00 2001 From: Maisem Ali Date: Thu, 14 Oct 2021 22:57:36 -0400 Subject: [PATCH] hostinfo: add EnvType for Kubernetes Signed-off-by: Maisem Ali --- hostinfo/hostinfo.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hostinfo/hostinfo.go b/hostinfo/hostinfo.go index 9b9eb8959..959450c70 100644 --- a/hostinfo/hostinfo.go +++ b/hostinfo/hostinfo.go @@ -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 +}