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
This commit is contained in:
Bryan Boreham
2018-02-19 17:31:02 +00:00
parent b742846835
commit dc1b768e73

View File

@@ -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
}