Skip to content

Commit

Permalink
Merge pull request #21 from sjc960115/master
Browse files Browse the repository at this point in the history
add node LabelSelector field
  • Loading branch information
robscott authored Nov 27, 2019
2 parents e48cbbb + 2cc7be2 commit 86e9ce8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/capacity/capacity.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func FetchAndPrint(showContainers, showPods, showUtil bool, podLabels, nodeLabel
}

pmList = getPodMetrics(mClientset)
nmList = getNodeMetrics(mClientset)
nmList = getNodeMetrics(mClientset, nodeLabels)
}

cm := buildClusterMetric(podList, pmList, nodeList, nmList)
Expand Down Expand Up @@ -129,8 +129,10 @@ func getPodMetrics(mClientset *metrics.Clientset) *v1beta1.PodMetricsList {
return pmList
}

func getNodeMetrics(mClientset *metrics.Clientset) *v1beta1.NodeMetricsList {
nmList, err := mClientset.MetricsV1beta1().NodeMetricses().List(metav1.ListOptions{})
func getNodeMetrics(mClientset *metrics.Clientset, nodeLabels string) *v1beta1.NodeMetricsList {
nmList, err := mClientset.MetricsV1beta1().NodeMetricses().List(metav1.ListOptions{
LabelSelector: nodeLabels,
})
if err != nil {
fmt.Printf("Error getting Node Metrics: %v\n", err)
fmt.Println("For this to work, metrics-server needs to be running in your cluster")
Expand Down

0 comments on commit 86e9ce8

Please sign in to comment.