summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/agent/hostinfo/hostinfo.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/go/collectors/go.d.plugin/agent/hostinfo/hostinfo.go')
-rw-r--r--src/go/collectors/go.d.plugin/agent/hostinfo/hostinfo.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/go/collectors/go.d.plugin/agent/hostinfo/hostinfo.go b/src/go/collectors/go.d.plugin/agent/hostinfo/hostinfo.go
index b395b61c6f..48508a1c86 100644
--- a/src/go/collectors/go.d.plugin/agent/hostinfo/hostinfo.go
+++ b/src/go/collectors/go.d.plugin/agent/hostinfo/hostinfo.go
@@ -5,6 +5,7 @@ package hostinfo
import (
"bytes"
"context"
+ "os"
"os/exec"
"time"
)
@@ -27,3 +28,12 @@ func getHostname() string {
return string(bytes.TrimSpace(bs))
}
+
+var (
+ envKubeHost = os.Getenv("KUBERNETES_SERVICE_HOST")
+ envKubePort = os.Getenv("KUBERNETES_SERVICE_PORT")
+)
+
+func IsInsideK8sCluster() bool {
+ return envKubeHost != "" && envKubePort != ""
+}