Merge branch 'master' into master

This commit is contained in:
richardxz
2018-06-20 11:26:01 +08:00
committed by GitHub
433 changed files with 32551 additions and 4234 deletions

View File

@@ -27,6 +27,8 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/informers"
"k8s.io/client-go/tools/cache"
"kubesphere.io/kubesphere/pkg/models/metrics"
)
const inUse = "in_use_pods"
@@ -262,6 +264,22 @@ func (ctl *PodCtl) ListWithConditions(conditions string, paging *Paging) (int, i
listWithConditions(ctl.DB, &total, &object, &list, conditions, paging, order)
ch := make(chan metrics.PodMetrics)
for index, _ := range list {
go metrics.GetSinglePodMetrics(list[index].Namespace, list[index].Name, ch)
}
var resultMetrics = make(map[string]metrics.PodMetrics)
for range list {
podMetric := <-ch
resultMetrics[podMetric.PodName] = podMetric
}
for index, _ := range list {
list[index].Metrics = resultMetrics[list[index].Name]
}
return total, list, nil
}

View File

@@ -26,6 +26,8 @@ import (
"github.com/jinzhu/gorm"
"k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes"
"kubesphere.io/kubesphere/pkg/models/metrics"
)
const (