1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

topology-updater: use node IP in the default configz URI

Use a separate NODE_ADDRESS environment variable in the default value of
-kubelet-config-uri (instead of NODE_NAME that was previously used).
Also change the kustomize and Helm deployments to set this variable to
node IP address. This should make the default deployment more robust,
making it work in scenarios where node name does not resolve to the node
ip, e.g. nodename != hostname.
This commit is contained in:
Markus Lehtonen 2023-05-05 12:35:44 +03:00
parent cd45baef8d
commit 1200fd05c5
5 changed files with 21 additions and 5 deletions

View file

@ -112,12 +112,13 @@ func parseArgs(flags *flag.FlagSet, osArgs ...string) (*topology.Args, *resource
}
if len(resourcemonitorArgs.KubeletConfigURI) == 0 {
if len(utils.NodeName()) == 0 {
fmt.Fprintf(flags.Output(), "unable to determine the default kubelet config endpoint 'https://${NODE_NAME}:%d/configz' due to empty NODE_NAME environment, "+
"please either define the NODE_NAME environment variable or specify endpoint with the -kubelet-config-uri flag\n", kubeletSecurePort)
nodeAddress := os.Getenv("NODE_ADDRESS")
if len(nodeAddress) == 0 {
fmt.Fprintf(flags.Output(), "unable to determine the default kubelet config endpoint 'https://${NODE_ADDRESS}:%d/configz' due to empty NODE_ADDRESS environment, "+
"please either define the NODE_ADDRESS environment variable or specify endpoint with the -kubelet-config-uri flag\n", kubeletSecurePort)
os.Exit(1)
}
resourcemonitorArgs.KubeletConfigURI = fmt.Sprintf("https://%s:%d/configz", utils.NodeName(), kubeletSecurePort)
resourcemonitorArgs.KubeletConfigURI = fmt.Sprintf("https://%s:%d/configz", nodeAddress, kubeletSecurePort)
}
return args, resourcemonitorArgs

View file

@ -0,0 +1,7 @@
- op: add
path: "/spec/template/spec/containers/0/env/-"
value:
name: NODE_ADDRESS
valueFrom:
fieldRef:
fieldPath: status.hostIP

View file

@ -14,3 +14,7 @@ patches:
target:
labelSelector: app=nfd
name: nfd-topology-updater
- path: env.yaml
target:
labelSelector: app=nfd
name: nfd-topology-updater

View file

@ -37,6 +37,10 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: NODE_ADDRESS
valueFrom:
fieldRef:
fieldPath: status.hostIP
command:
- "nfd-topology-updater"
args:

View file

@ -109,7 +109,7 @@ nfd-topology-updater -watch-namespace=rte
The `-kubelet-config-uri` specifies the path to the Kubelet's configuration.
Note that the URi could either be a local host file or an HTTP endpoint.
Default: `https://${NODE_NAME}:10250/configz`
Default: `https://${NODE_ADDRESS}:10250/configz`
Example: