本文整理汇总了Golang中github.com/kubernetes/dashboard/src/app/backend/resource/common.GetPodInfo函数的典型用法代码示例。如果您正苦于以下问题:Golang GetPodInfo函数的具体用法?Golang GetPodInfo怎么用?Golang GetPodInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetPodInfo函数的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: 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
示例4: getPetSetPodInfo
// Returns simple info about pods(running, desired, failing, etc.) related to given pet set.
func getPetSetPodInfo(client *k8sClient.Client, petSet *apps.PetSet) (
*common.PodInfo, error) {
pods, err := getRawPetSetPods(client, petSet.Name, petSet.Namespace)
if err != nil {
return nil, err
}
podInfo := common.GetPodInfo(int32(petSet.Status.Replicas), int32(petSet.Spec.Replicas), pods)
return &podInfo, nil
}
开发者ID:digitalfishpond,项目名称:dashboard,代码行数:12,代码来源:petsetpods.go
示例5: getDaemonSetPodInfo
// Returns simple info about pods(running, desired, failing, etc.) related to given daemon set.
func getDaemonSetPodInfo(client k8sClient.Interface, daemonSet *extensions.DaemonSet) (
*common.PodInfo, error) {
pods, err := getRawDaemonSetPods(client, daemonSet.Name, daemonSet.Namespace)
if err != nil {
return nil, err
}
podInfo := common.GetPodInfo(daemonSet.Status.CurrentNumberScheduled,
daemonSet.Status.DesiredNumberScheduled, pods)
return &podInfo, nil
}
开发者ID:kubernetes,项目名称:dashboard,代码行数:13,代码来源:daemonsetpods.go
示例6: getJobPodInfo
// Returns simple info about pods(running, desired, failing, etc.) related to given job.
func getJobPodInfo(client k8sClient.Interface, job *batch.Job) (*common.PodInfo, error) {
labelSelector := labels.SelectorFromSet(job.Spec.Selector.MatchLabels)
channels := &common.ResourceChannels{
PodList: common.GetPodListChannelWithOptions(client, common.NewSameNamespaceQuery(
job.Namespace),
api.ListOptions{
LabelSelector: labelSelector,
FieldSelector: fields.Everything(),
}, 1),
}
pods := <-channels.PodList.List
if err := <-channels.PodList.Error; err != nil {
return nil, err
}
podInfo := common.GetPodInfo(job.Status.Active, *job.Spec.Completions, pods.Items)
return &podInfo, nil
}
开发者ID:bryk,项目名称:dashboard,代码行数:20,代码来源:jobpods.go
示例7: getReplicationControllerPodInfo
// Returns simple info about pods(running, desired, failing, etc.) related to given replication
// controller.
func getReplicationControllerPodInfo(client k8sClient.Interface, rc *api.ReplicationController,
namespace string) (*common.PodInfo, error) {
labelSelector := labels.SelectorFromSet(rc.Spec.Selector)
channels := &common.ResourceChannels{
PodList: common.GetPodListChannelWithOptions(client, common.NewSameNamespaceQuery(namespace),
api.ListOptions{
LabelSelector: labelSelector,
FieldSelector: fields.Everything(),
}, 1),
}
pods := <-channels.PodList.List
if err := <-channels.PodList.Error; err != nil {
return nil, err
}
podInfo := common.GetPodInfo(rc.Status.Replicas, rc.Spec.Replicas, pods.Items)
return &podInfo, nil
}
开发者ID:bryk,项目名称:dashboard,代码行数:22,代码来源:replicationcontrollerpods.go
示例8: 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
示例9: GetDeploymentDetail
// GetDeploymentDetail returns model object of deployment and error, if any.
func GetDeploymentDetail(client client.Interface, heapsterClient heapster.HeapsterClient, namespace string,
deploymentName string) (*DeploymentDetail, error) {
log.Printf("Getting details of %s deployment in %s namespace", deploymentName, namespace)
deployment, err := client.Extensions().Deployments(namespace).Get(deploymentName)
if err != nil {
return nil, err
}
selector, err := unversioned.LabelSelectorAsSelector(deployment.Spec.Selector)
if err != nil {
return nil, err
}
options := api.ListOptions{LabelSelector: selector}
channels := &common.ResourceChannels{
ReplicaSetList: common.GetReplicaSetListChannelWithOptions(client.Extensions(),
common.NewSameNamespaceQuery(namespace), options, 1),
PodList: common.GetPodListChannelWithOptions(client,
common.NewSameNamespaceQuery(namespace), options, 1),
}
rawRs := <-channels.ReplicaSetList.List
if err := <-channels.ReplicaSetList.Error; err != nil {
return nil, err
}
rawPods := <-channels.PodList.List
if err := <-channels.PodList.Error; err != nil {
return nil, err
}
// Pods
podList, err := GetDeploymentPods(client, heapsterClient, dataselect.DefaultDataSelectWithMetrics, namespace, deploymentName)
if err != nil {
return nil, err
}
// Events
eventList, err := GetDeploymentEvents(client, dataselect.DefaultDataSelect, namespace, deploymentName)
if err != nil {
return nil, err
}
// Old Replica Sets
oldReplicaSetList, err := GetDeploymentOldReplicaSets(client, dataselect.DefaultDataSelect, namespace, deploymentName)
if err != nil {
return nil, err
}
// New Replica Set
newRs, err := deploymentutil.FindNewReplicaSet(deployment, rawRs.Items)
if err != nil {
return nil, err
}
var newReplicaSet replicaset.ReplicaSet
if newRs != nil {
newRsPodInfo := common.GetPodInfo(newRs.Status.Replicas, newRs.Spec.Replicas, rawPods.Items)
newReplicaSet = replicaset.ToReplicaSet(newRs, &newRsPodInfo)
}
// Extra Info
var rollingUpdateStrategy *RollingUpdateStrategy
if deployment.Spec.Strategy.RollingUpdate != nil {
rollingUpdateStrategy = &RollingUpdateStrategy{
MaxSurge: deployment.Spec.Strategy.RollingUpdate.MaxSurge.IntValue(),
MaxUnavailable: deployment.Spec.Strategy.RollingUpdate.MaxUnavailable.IntValue(),
}
}
return &DeploymentDetail{
ObjectMeta: common.NewObjectMeta(deployment.ObjectMeta),
TypeMeta: common.NewTypeMeta(common.ResourceKindDeployment),
PodList: *podList,
Selector: deployment.Spec.Selector.MatchLabels,
StatusInfo: GetStatusInfo(&deployment.Status),
Strategy: deployment.Spec.Strategy.Type,
MinReadySeconds: deployment.Spec.MinReadySeconds,
RollingUpdateStrategy: rollingUpdateStrategy,
OldReplicaSetList: *oldReplicaSetList,
NewReplicaSet: newReplicaSet,
RevisionHistoryLimit: deployment.Spec.RevisionHistoryLimit,
EventList: *eventList,
}, nil
}
开发者ID:digitalfishpond,项目名称:dashboard,代码行数:86,代码来源:deploymentdetail.go
注:本文中的github.com/kubernetes/dashboard/src/app/backend/resource/common.GetPodInfo函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论