Skip to content

Commit 32ce5e4

Browse files
fntlnzleodido
andcommitted
feat(cmd/run): infer hostname from node name
Co-authored-by: Leonardo Di Donato <[email protected]> Signed-off-by: Lorenzo Fontana <[email protected]>
1 parent db380b1 commit 32ce5e4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/cmd/run.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,12 @@ func (o *RunOptions) Complete(factory factory.Factory, cmd *cobra.Command, args
184184
return fmt.Errorf("running bpftrace programs against pods is not supported yet, see: https://github.com/fntlnz/kubectl-trace/issues/3")
185185
break
186186
case *v1.Node:
187-
o.nodeName = v.GetName()
187+
labels := v.GetLabels()
188+
val, ok := labels["kubernetes.io/hostname"]
189+
if !ok {
190+
return fmt.Errorf("label kubernetes.io/hostname not found in node")
191+
}
192+
o.nodeName = val
188193
break
189194
default:
190195
return fmt.Errorf("first argument must be %s", usageString)

0 commit comments

Comments
 (0)