diff --git a/pkg/node/types/nodename.go b/pkg/node/types/nodename.go index 16c7d664cd01..7fcc02628c4c 100644 --- a/pkg/node/types/nodename.go +++ b/pkg/node/types/nodename.go @@ -1,4 +1,4 @@ -// Copyright 2016-2017 Authors of Cilium +// Copyright 2016-2020 Authors of Cilium // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package types import ( "os" + k8sConsts "github.com/cilium/cilium/pkg/k8s/constants" "github.com/cilium/cilium/pkg/logging/logfields" ) @@ -42,6 +43,11 @@ func GetName() string { } func init() { + // Give priority to the environment variable available in the Cilium agent + if name := os.Getenv(k8sConsts.EnvNodeNameSpec); name != "" { + nodeName = name + return + } if h, err := os.Hostname(); err != nil { log.WithError(err).Warn("Unable to retrieve local hostname") } else {