Ejemplo n.º 1
0
func ToJob(job *batch.Job, podInfo *common.PodInfo) Job {
	return Job{
		ObjectMeta:      common.NewObjectMeta(job.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindJob),
		ContainerImages: common.GetContainerImages(&job.Spec.Template.Spec),
		Pods:            *podInfo,
	}
}
Ejemplo n.º 2
0
// ToReplicaSet converts replica set api object to replica set model object.
func ToReplicaSet(replicaSet *extensions.ReplicaSet, podInfo *common.PodInfo) ReplicaSet {
	return ReplicaSet{
		ObjectMeta:      common.NewObjectMeta(replicaSet.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindReplicaSet),
		ContainerImages: common.GetContainerImages(&replicaSet.Spec.Template.Spec),
		Pods:            *podInfo,
	}
}
Ejemplo n.º 3
0
// ToPetSet transforms pet set into PetSet object returned by API.
func ToPetSet(petSet *apps.PetSet, podInfo *common.PodInfo) PetSet {
	return PetSet{
		ObjectMeta:      common.NewObjectMeta(petSet.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindPetSet),
		ContainerImages: common.GetContainerImages(&petSet.Spec.Template.Spec),
		Pods:            *podInfo,
	}
}
Ejemplo n.º 4
0
// ToStatefulSet transforms pet set into StatefulSet object returned by API.
func ToStatefulSet(statefulSet *apps.StatefulSet, podInfo *common.PodInfo) StatefulSet {
	return StatefulSet{
		ObjectMeta:      common.NewObjectMeta(statefulSet.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindStatefulSet),
		ContainerImages: common.GetContainerImages(&statefulSet.Spec.Template.Spec),
		Pods:            *podInfo,
	}
}
// ToReplicationController converts replication controller api object to replication controller
// model object.
func ToReplicationController(replicationController *api.ReplicationController,
	podInfo *common.PodInfo) ReplicationController {

	return ReplicationController{
		ObjectMeta:      common.NewObjectMeta(replicationController.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindReplicationController),
		Pods:            *podInfo,
		ContainerImages: common.GetContainerImages(&replicationController.Spec.Template.Spec),
	}
}
Ejemplo n.º 6
0
func getPetSetDetail(petSet *apps.PetSet, heapsterClient client.HeapsterClient,
	eventList common.EventList, podList pod.PodList, podInfo common.PodInfo) PetSetDetail {

	return PetSetDetail{
		ObjectMeta:      common.NewObjectMeta(petSet.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindPetSet),
		ContainerImages: common.GetContainerImages(&petSet.Spec.Template.Spec),
		PodInfo:         podInfo,
		PodList:         podList,
		EventList:       eventList,
	}
}
Ejemplo n.º 7
0
func getJobDetail(job *batch.Job, heapsterClient client.HeapsterClient,
	eventList common.EventList, podList pod.PodList, podInfo common.PodInfo) JobDetail {
	return JobDetail{
		ObjectMeta:      common.NewObjectMeta(job.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindJob),
		ContainerImages: common.GetContainerImages(&job.Spec.Template.Spec),
		PodInfo:         podInfo,
		PodList:         podList,
		EventList:       eventList,
		Parallelism:     job.Spec.Parallelism,
		Completions:     job.Spec.Completions,
	}
}
Ejemplo n.º 8
0
// ToReplicaSetDetail converts replica set api object to replica set detail model object.
func ToReplicaSetDetail(replicaSet *extensions.ReplicaSet, eventList common.EventList,
	podList pod.PodList, podInfo common.PodInfo, serviceList resourceService.ServiceList) ReplicaSetDetail {

	return ReplicaSetDetail{
		ObjectMeta:      common.NewObjectMeta(replicaSet.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindReplicaSet),
		ContainerImages: common.GetContainerImages(&replicaSet.Spec.Template.Spec),
		Selector:        replicaSet.Spec.Selector,
		PodInfo:         podInfo,
		PodList:         podList,
		ServiceList:     serviceList,
		EventList:       eventList,
	}
}
// ToReplicationControllerDetail converts replication controller api object to replication
// controller detail model object.
func ToReplicationControllerDetail(replicationController *api.ReplicationController,
	podInfo common.PodInfo, podList pod.PodList, eventList common.EventList,
	serviceList resourceService.ServiceList) ReplicationControllerDetail {

	replicationControllerDetail := ReplicationControllerDetail{
		ObjectMeta:      common.NewObjectMeta(replicationController.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindReplicationController),
		LabelSelector:   replicationController.Spec.Selector,
		PodInfo:         podInfo,
		PodList:         podList,
		EventList:       eventList,
		ServiceList:     serviceList,
		ContainerImages: common.GetContainerImages(&replicationController.Spec.Template.Spec),
	}

	return replicationControllerDetail
}
Ejemplo n.º 10
0
// 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
}