Skip to content

Commit

Permalink
Merge pull request #1218 from marquiz/devel/configz-uri
Browse files Browse the repository at this point in the history
topology-updater: use node IP in the default configz URI
  • Loading branch information
k8s-ci-robot authored May 5, 2023
2 parents cd45bae + 1200fd0 commit ef92b2f
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)
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
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 ef92b2f

Please sign in to comment.