From dc1b768e73001f9a6670f80bca2036a81748c081 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 19 Feb 2018 17:31:02 +0000 Subject: [PATCH] Allow Kubernetes node-name to be set from env var If we have the node-name then we can save work requesting the list of local pods from kubelet. And the best way to get the node name is via the "downwards api", i.e. put this in the Daemonset Yaml: - name: KUBERNETES_NODENAME valueFrom: fieldRef: apiVersion: v1 fieldPath: spec.nodeName --- prog/main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/prog/main.go b/prog/main.go index 7d72262b1..11686ae16 100644 --- a/prog/main.go +++ b/prog/main.go @@ -428,6 +428,11 @@ func main() { } } + // Node name may be set by environment variable, e.g. from the Kubernetes downward API + if flags.probe.kubernetesNodeName == "" { + flags.probe.kubernetesNodeName = os.Getenv("KUBERNETES_NODENAME") + } + if flags.dryRun { return }