Home > OS >  how to get only one node name from kubectl get nodes
how to get only one node name from kubectl get nodes

Time:01-01

Is there any way that kubectl get nodes would output for example only one node name without any other info just the name? for example node ending with 1.

so instead of something like this:

NAME                                STATUS   ROLES   AGE   VERSION
aks-nodepool1-00000000-vmss000000   Ready    agent   1m   v1.23.12
aks-nodepool1-00000000-vmss000001   Ready    agent   1m   v1.23.12

just this aks-nodepool1-00000000-vmss000001

CodePudding user response:

You can use the output option:

 -o, --output='':
        Output format. One of: (json, yaml, name, go-template, go-template-file, template, templatefile, jsonpath,
        jsonpath-as-json, jsonpath-file, custom-columns, custom-columns-file, wide). See custom columns
        [https://kubernetes.io/docs/reference/kubectl/overview/#custom-columns], golang template
        [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template
        [https://kubernetes.io/docs/reference/kubectl/jsonpath/].

So you can do

kubectl get nodes --output name
  • Related