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 node IP (instead of node name) in the default value of
-kubelet-config-uri. 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 9e437e4
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)
nodeIP := os.Getenv("NODE_IP")
if len(nodeIP) == 0 {
fmt.Fprintf(flags.Output(), "unable to determine the default kubelet config endpoint 'https://${NODE_IP}:%d/configz' due to empty NODE_IP environment, "+
"please either define the NODE_IP 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", nodeIP, 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_IP
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_IP
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_IP}:10250/configz`

Example:

Expand Down

0 comments on commit 9e437e4

Please sign in to comment.