本文整理汇总了Golang中github.com/kubernetes/dashboard/src/app/backend/resource/dataselect.GenericDataSelectWithMetrics函数的典型用法代码示例。如果您正苦于以下问题:Golang GenericDataSelectWithMetrics函数的具体用法?Golang GenericDataSelectWithMetrics怎么用?Golang GenericDataSelectWithMetrics使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GenericDataSelectWithMetrics函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: CreatePetSetList
// CreatePetSetList creates paginated list of Pet Set model
// objects based on Kubernetes Pet Set objects array and related resources arrays.
func CreatePetSetList(petSets []apps.PetSet, pods []api.Pod, events []api.Event,
dsQuery *dataselect.DataSelectQuery, heapsterClient *heapster.HeapsterClient) *PetSetList {
petSetList := &PetSetList{
PetSets: make([]PetSet, 0),
ListMeta: common.ListMeta{TotalItems: len(petSets)},
}
cachedResources := &dataselect.CachedResources{
Pods: pods,
}
replicationControllerCells, metricPromises := dataselect.GenericDataSelectWithMetrics(petset.ToCells(petSets), dsQuery, cachedResources, heapsterClient)
petSets = petset.FromCells(replicationControllerCells)
for _, petSet := range petSets {
matchingPods := common.FilterNamespacedPodsBySelector(pods, petSet.ObjectMeta.Namespace,
petSet.Spec.Selector.MatchLabels)
// TODO(floreks): Conversion should be omitted when client type will be updated
podInfo := common.GetPodInfo(int32(petSet.Status.Replicas), int32(petSet.Spec.Replicas),
matchingPods)
podInfo.Warnings = event.GetPodsEventWarnings(events, matchingPods)
petSetList.PetSets = append(petSetList.PetSets, ToPetSet(&petSet, &podInfo))
}
cumulativeMetrics, err := metricPromises.GetMetrics()
petSetList.CumulativeMetrics = cumulativeMetrics
if err != nil {
petSetList.CumulativeMetrics = make([]metric.Metric, 0)
}
return petSetList
}
开发者ID:cheld,项目名称:dashboard,代码行数:35,代码来源:petsetlist.go
示例2: CreateReplicaSetList
// CreateReplicaSetList creates paginated list of Replica Set model
// objects based on Kubernetes Replica Set objects array and related resources arrays.
func CreateReplicaSetList(replicaSets []extensions.ReplicaSet, pods []api.Pod,
events []api.Event, dsQuery *dataselect.DataSelectQuery, heapsterClient *heapster.HeapsterClient) *ReplicaSetList {
replicaSetList := &ReplicaSetList{
ReplicaSets: make([]replicaset.ReplicaSet, 0),
ListMeta: common.ListMeta{TotalItems: len(replicaSets)},
}
cachedResources := &dataselect.CachedResources{
Pods: pods,
}
replicationControllerCells, metricPromises := dataselect.GenericDataSelectWithMetrics(replicaset.ToCells(replicaSets), dsQuery, cachedResources, heapsterClient)
replicaSets = replicaset.FromCells(replicationControllerCells)
for _, replicaSet := range replicaSets {
matchingPods := common.FilterNamespacedPodsBySelector(pods, replicaSet.ObjectMeta.Namespace,
replicaSet.Spec.Selector.MatchLabels)
podInfo := common.GetPodInfo(replicaSet.Status.Replicas,
replicaSet.Spec.Replicas, matchingPods)
podInfo.Warnings = event.GetPodsEventWarnings(events, matchingPods)
replicaSetList.ReplicaSets = append(replicaSetList.ReplicaSets, replicaset.ToReplicaSet(&replicaSet, &podInfo))
}
cumulativeMetrics, err := metricPromises.GetMetrics()
replicaSetList.CumulativeMetrics = cumulativeMetrics
if err != nil {
replicaSetList.CumulativeMetrics = make([]metric.Metric, 0)
}
return replicaSetList
}
开发者ID:cheld,项目名称:dashboard,代码行数:34,代码来源:replicasetlist.go
示例3: CreatePodList
func CreatePodList(pods []api.Pod, dsQuery *dataselect.DataSelectQuery,
heapsterClient client.HeapsterClient) PodList {
channels := &common.ResourceChannels{
PodMetrics: common.GetPodListMetricsChannel(heapsterClient, pods, 1),
}
if err := <-channels.PodMetrics.Error; err != nil {
log.Printf("Skipping Heapster metrics because of error: %s\n", err)
}
metrics := <-channels.PodMetrics.MetricsByPod
podList := PodList{
Pods: make([]Pod, 0),
ListMeta: common.ListMeta{TotalItems: len(pods)},
}
podCells, cumulativeMetricsPromises := dataselect.GenericDataSelectWithMetrics(toCells(pods), dsQuery,
dataselect.NoResourceCache, &heapsterClient)
pods = fromCells(podCells)
for _, pod := range pods {
podDetail := ToPod(&pod, metrics)
podList.Pods = append(podList.Pods, podDetail)
}
cumulativeMetrics, err := cumulativeMetricsPromises.GetMetrics()
podList.CumulativeMetrics = cumulativeMetrics
if err != nil {
podList.CumulativeMetrics = make([]metric.Metric, 0)
}
return podList
}
开发者ID:digitalfishpond,项目名称:dashboard,代码行数:34,代码来源:podlist.go
示例4: GetNodeDetail
// GetNodeDetail gets node details.
func GetNodeDetail(client k8sClient.Interface, heapsterClient client.HeapsterClient, name string) (*NodeDetail, error) {
log.Printf("Getting details of %s node", name)
node, err := client.Core().Nodes().Get(name)
if err != nil {
return nil, err
}
// Download standard metrics. Currently metrics are hard coded, but it is possible to replace
// dataselect.StdMetricsDataSelect with data select provided in the request.
_, metricPromises := dataselect.GenericDataSelectWithMetrics(toCells([]api.Node{*node}),
dataselect.StdMetricsDataSelect,
dataselect.NoResourceCache, &heapsterClient)
pods, err := getNodePods(client, *node)
if err != nil {
return nil, err
}
podList, err := GetNodePods(client, heapsterClient, dataselect.DefaultDataSelect, name)
eventList, err := event.GetNodeEvents(client, dataselect.DefaultDataSelect, node.Name)
if err != nil {
return nil, err
}
allocatedResources, err := getNodeAllocatedResources(*node, pods)
if err != nil {
return nil, err
}
metrics, _ := metricPromises.GetMetrics()
nodeDetails := toNodeDetail(*node, podList, eventList, allocatedResources, metrics)
return &nodeDetails, nil
}
开发者ID:floreks,项目名称:dashboard,代码行数:36,代码来源:nodedetail.go
示例5: CreateJobList
// CreateJobList returns a list of all Job model objects in the cluster, based on all
// Kubernetes Job API objects.
func CreateJobList(jobs []batch.Job, pods []api.Pod, events []api.Event,
dsQuery *dataselect.DataSelectQuery, heapsterClient *heapster.HeapsterClient) *JobList {
jobList := &JobList{
Jobs: make([]Job, 0),
ListMeta: common.ListMeta{TotalItems: len(jobs)},
}
cachedResources := &dataselect.CachedResources{
Pods: pods,
}
replicationControllerCells, metricPromises := dataselect.GenericDataSelectWithMetrics(toCells(jobs), dsQuery, cachedResources, heapsterClient)
jobs = fromCells(replicationControllerCells)
for _, job := range jobs {
var completions int32
matchingPods := common.FilterNamespacedPodsBySelector(pods, job.ObjectMeta.Namespace,
job.Spec.Selector.MatchLabels)
if job.Spec.Completions != nil {
completions = *job.Spec.Completions
}
podInfo := common.GetPodInfo(job.Status.Active, completions, matchingPods)
podInfo.Warnings = event.GetPodsEventWarnings(events, matchingPods)
jobList.Jobs = append(jobList.Jobs, ToJob(&job, &podInfo))
}
cumulativeMetrics, err := metricPromises.GetMetrics()
jobList.CumulativeMetrics = cumulativeMetrics
if err != nil {
jobList.CumulativeMetrics = make([]metric.Metric, 0)
}
return jobList
}
开发者ID:digitalfishpond,项目名称:dashboard,代码行数:37,代码来源:joblist.go
示例6: GetPodDetail
// GetPodDetail returns the details (PodDetail) of a named Pod from a particular
// namespace.
func GetPodDetail(client k8sClient.Interface, heapsterClient client.HeapsterClient,
namespace, name string) (*PodDetail, error) {
log.Printf("Getting details of %s pod in %s namespace", name, namespace)
channels := &common.ResourceChannels{
ConfigMapList: common.GetConfigMapListChannel(client, common.NewSameNamespaceQuery(namespace), 1),
PodMetrics: common.GetPodMetricsChannel(heapsterClient, name, namespace),
}
pod, err := client.Pods(namespace).Get(name)
if err != nil {
return nil, err
}
// Download metrics
_, metricPromises := dataselect.GenericDataSelectWithMetrics(toCells([]api.Pod{*pod}),
dataselect.StdMetricsDataSelect, dataselect.NoResourceCache, &heapsterClient)
metrics, _ := metricPromises.GetMetrics()
if err = <-channels.ConfigMapList.Error; err != nil {
return nil, err
}
configMapList := <-channels.ConfigMapList.List
podDetail := toPodDetail(pod, metrics, configMapList)
return &podDetail, nil
}
开发者ID:digitalfishpond,项目名称:dashboard,代码行数:31,代码来源:poddetail.go
示例7: GetPodDetail
// GetPodDetail returns the details (PodDetail) of a named Pod from a particular
// namespace.
func GetPodDetail(client k8sClient.Interface, heapsterClient client.HeapsterClient,
namespace, name string) (*PodDetail, error) {
log.Printf("Getting details of %s pod in %s namespace", name, namespace)
channels := &common.ResourceChannels{
ConfigMapList: common.GetConfigMapListChannel(client, common.NewSameNamespaceQuery(namespace), 1),
PodMetrics: common.GetPodMetricsChannel(heapsterClient, name, namespace),
}
pod, err := client.Core().Pods(namespace).Get(name)
if err != nil {
return nil, err
}
controller := Controller{
Kind: "unknown",
}
creatorAnnotation, found := pod.ObjectMeta.Annotations[api.CreatedByAnnotation]
if found {
creatorRef, err := getPodCreator(client, creatorAnnotation, common.NewSameNamespaceQuery(namespace), heapsterClient)
if err != nil {
return nil, err
}
controller = *creatorRef
}
// Download metrics
_, metricPromises := dataselect.GenericDataSelectWithMetrics(toCells([]api.Pod{*pod}),
dataselect.StdMetricsDataSelect, dataselect.NoResourceCache, &heapsterClient)
metrics, _ := metricPromises.GetMetrics()
if err = <-channels.ConfigMapList.Error; err != nil {
return nil, err
}
configMapList := <-channels.ConfigMapList.List
podDetail := toPodDetail(pod, metrics, configMapList, controller)
return &podDetail, nil
}
开发者ID:floreks,项目名称:dashboard,代码行数:43,代码来源:poddetail.go
示例8: toNodeList
func toNodeList(nodes []api.Node, dsQuery *dataselect.DataSelectQuery, heapsterClient *heapster.HeapsterClient) *NodeList {
nodeList := &NodeList{
Nodes: make([]Node, 0),
ListMeta: common.ListMeta{TotalItems: len(nodes)},
}
replicationControllerCells, metricPromises := dataselect.GenericDataSelectWithMetrics(toCells(nodes), dsQuery, dataselect.NoResourceCache, heapsterClient)
nodes = fromCells(replicationControllerCells)
for _, node := range nodes {
nodeList.Nodes = append(nodeList.Nodes, toNode(node))
}
// this may be slow because heapster does not support all in one download for nodes.
cumulativeMetrics, err := metricPromises.GetMetrics()
nodeList.CumulativeMetrics = cumulativeMetrics
if err != nil {
nodeList.CumulativeMetrics = make([]metric.Metric, 0)
}
return nodeList
}
开发者ID:digitalfishpond,项目名称:dashboard,代码行数:22,代码来源:nodelist.go
示例9: CreateDeploymentList
// CreateDeploymentList returns a list of all Deployment model objects in the cluster, based on all
// Kubernetes Deployment API objects.
func CreateDeploymentList(deployments []extensions.Deployment, pods []api.Pod,
events []api.Event, dsQuery *dataselect.DataSelectQuery, heapsterClient *heapster.HeapsterClient) *DeploymentList {
deploymentList := &DeploymentList{
Deployments: make([]Deployment, 0),
ListMeta: common.ListMeta{TotalItems: len(deployments)},
}
cachedResources := &dataselect.CachedResources{
Pods: pods,
}
replicationControllerCells, metricPromises := dataselect.GenericDataSelectWithMetrics(toCells(deployments), dsQuery, cachedResources, heapsterClient)
deployments = fromCells(replicationControllerCells)
for _, deployment := range deployments {
matchingPods := common.FilterNamespacedPodsBySelector(pods, deployment.ObjectMeta.Namespace,
deployment.Spec.Selector.MatchLabels)
podInfo := common.GetPodInfo(deployment.Status.Replicas, deployment.Spec.Replicas,
matchingPods)
podInfo.Warnings = event.GetPodsEventWarnings(events, matchingPods)
deploymentList.Deployments = append(deploymentList.Deployments,
Deployment{
ObjectMeta: common.NewObjectMeta(deployment.ObjectMeta),
TypeMeta: common.NewTypeMeta(common.ResourceKindDeployment),
ContainerImages: common.GetContainerImages(&deployment.Spec.Template.Spec),
Pods: podInfo,
})
}
cumulativeMetrics, err := metricPromises.GetMetrics()
deploymentList.CumulativeMetrics = cumulativeMetrics
if err != nil {
deploymentList.CumulativeMetrics = make([]metric.Metric, 0)
}
return deploymentList
}
开发者ID:kubernetes,项目名称:dashboard,代码行数:41,代码来源:deploymentlist.go
注:本文中的github.com/kubernetes/dashboard/src/app/backend/resource/dataselect.GenericDataSelectWithMetrics函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论