Skip to content

Commit

Permalink
topology-updater: use node IP in the default configz URI
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
marquiz committed May 5, 2023
1 parent cd45bae commit 1200fd0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
9 changes: 5 additions & 4 deletions cmd/nfd-topology-updater/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 118 in cmd/nfd-topology-updater/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/nfd-topology-updater/main.go#L115-L118

Added lines #L115 - L118 were not covered by tests
os.Exit(1)
}
resourcemonitorArgs.KubeletConfigURI = fmt.Sprintf("https://%s:%d/configz", utils.NodeName(), kubeletSecurePort)
resourcemonitorArgs.KubeletConfigURI = fmt.Sprintf("https://%s:%d/configz", nodeAddress, kubeletSecurePort)

Check warning on line 121 in cmd/nfd-topology-updater/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/nfd-topology-updater/main.go#L121

Added line #L121 was not covered by tests
}

return args, resourcemonitorArgs
Expand Down
7 changes: 7 additions & 0 deletions deployment/components/topology-updater/env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- op: add
path: "/spec/template/spec/containers/0/env/-"
value:
name: NODE_ADDRESS
valueFrom:
fieldRef:
fieldPath: status.hostIP
4 changes: 4 additions & 0 deletions deployment/components/topology-updater/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ patches:
target:
labelSelector: app=nfd
name: nfd-topology-updater
- path: env.yaml
target:
labelSelector: app=nfd
name: nfd-topology-updater
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: NODE_ADDRESS
valueFrom:
fieldRef:
fieldPath: status.hostIP
command:
- "nfd-topology-updater"
args:
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/topology-updater-commandline-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit 1200fd0

Please sign in to comment.