Skip to content

Commit

Permalink
remove LabelSelector when list cluster nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuguangming committed Jan 28, 2021
1 parent 82f4595 commit 9fd6f40
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pkg/yurtctl/cmd/clusterinfo/clusterinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,22 @@ import (

"github.com/alibaba/openyurt/pkg/projectinfo"
kubeutil "github.com/alibaba/openyurt/pkg/yurtctl/util/kubernetes"

)

// ClusterInfoOptions has the information that required by cluster-info operation
type ClusterInfoOptions struct {
clientSet *kubernetes.Clientset
CloudNodes []string
EdgeNodes []string
YurtNodes []string
ClusterNodes []string
}

// NewClusterInfoOptions creates a new ClusterInfoOptions
func NewClusterInfoOptions() *ClusterInfoOptions {
return &ClusterInfoOptions{
CloudNodes: []string{},
EdgeNodes: []string{},
YurtNodes: []string{},
CloudNodes: []string{},
EdgeNodes: []string{},
ClusterNodes: []string{},
}
}

Expand Down Expand Up @@ -87,12 +86,12 @@ func (o *ClusterInfoOptions) Validate() error {
func (o *ClusterInfoOptions) Run() (err error) {
// 1. list openyurt cluster node
key := projectinfo.GetEdgeWorkerLabelKey()
Nodes, err := o.clientSet.CoreV1().Nodes().List(metav1.ListOptions{LabelSelector: key})
Nodes, err := o.clientSet.CoreV1().Nodes().List(metav1.ListOptions{})
if err != nil {
return
}
for _, node := range Nodes.Items {
o.YurtNodes = append(o.YurtNodes, node.Name)
o.ClusterNodes = append(o.ClusterNodes, node.Name)
// 2. cloud node
if node.Labels[key] == "false" {
o.CloudNodes = append(o.CloudNodes, node.Name)
Expand All @@ -103,7 +102,7 @@ func (o *ClusterInfoOptions) Run() (err error) {
}

}
printClusterInfo(os.Stdout, "openyurt cluster", o.YurtNodes)
printClusterInfo(os.Stdout, "kubernetes cluster", o.ClusterNodes)
printClusterInfo(os.Stdout, "openyurt cloud", o.CloudNodes)
printClusterInfo(os.Stdout, "openyurt edge", o.EdgeNodes)
return
Expand Down

0 comments on commit 9fd6f40

Please sign in to comment.