@@ -19,6 +19,11 @@ import (
1919 _ "k8s.io/client-go/plugin/pkg/client/auth"
2020)
2121
22+ const (
23+ karpenterLabel string = "karpenter.sh/provisioner-name"
24+ karpenterNodeFmtStr string = "(Karpenter) %s"
25+ )
26+
2227var (
2328 noHeaders bool
2429 onlyName bool
@@ -102,6 +107,12 @@ func findNodepool(node corev1.Node, label string) string {
102107 if np , ok := node .Labels [label ]; ok {
103108 return np
104109 }
110+
111+ // check for karpenter nodes
112+ if np , ok := node .Labels [karpenterLabel ]; ok {
113+ return fmt .Sprintf (karpenterNodeFmtStr , np )
114+ }
115+
105116 for _ , lbl := range providerNodepoolLabels {
106117 if np , ok := node .Labels [lbl ]; ok {
107118 return np
@@ -125,7 +136,7 @@ func instanceType(node corev1.Node) string {
125136
126137type nodepool struct {
127138 Name string
128- Type string
139+ Types map [ string ] bool
129140 Nodes uint
130141}
131142
@@ -155,9 +166,13 @@ func listCmd() *cobra.Command {
155166 names = append (names , npName )
156167 np = & nodepool {
157168 Name : npName ,
158- Type : instanceType (n ),
169+ Types : map [string ]bool {
170+ instanceType (n ): true ,
171+ },
159172 }
160173 nps [npName ] = np
174+ } else {
175+ np .Types [instanceType (n )] = true
161176 }
162177 np .Nodes += 1
163178 }
@@ -178,7 +193,12 @@ func listCmd() *cobra.Command {
178193 if onlyName {
179194 fmt .Fprintln (w , np .Name )
180195 } else {
181- fmt .Fprintf (w , "%s\t %5d\t %s\n " , np .Name , np .Nodes , np .Type )
196+ typeList := make ([]string , 0 , len (np .Types ))
197+ for k := range np .Types {
198+ typeList = append (typeList , k )
199+ }
200+ sort .Strings (typeList )
201+ fmt .Fprintf (w , "%s\t %5d\t %s\n " , np .Name , np .Nodes , strings .Join (typeList , ", " ))
182202 }
183203 }
184204
0 commit comments