예제 #1
0
// GetStatefulSetDetail gets pet set details.
func GetStatefulSetDetail(client *k8sClient.Clientset, heapsterClient client.HeapsterClient,
	namespace, name string) (*StatefulSetDetail, error) {

	log.Printf("Getting details of %s service in %s namespace", name, namespace)

	// TODO(floreks): Use channels.
	statefulSetData, err := client.Apps().StatefulSets(namespace).Get(name)
	if err != nil {
		return nil, err
	}

	podList, err := GetStatefulSetPods(client, heapsterClient, dataselect.DefaultDataSelectWithMetrics, name, namespace)
	if err != nil {
		return nil, err
	}

	podInfo, err := getStatefulSetPodInfo(client, statefulSetData)
	if err != nil {
		return nil, err
	}

	events, err := GetStatefulSetEvents(client, dataselect.DefaultDataSelect, statefulSetData.Namespace, statefulSetData.Name)
	if err != nil {
		return nil, err
	}

	statefulSet := getStatefulSetDetail(statefulSetData, heapsterClient, *events, *podList, *podInfo)
	return &statefulSet, nil
}
예제 #2
0
// GetStatefulSetPodsEvents gets events associated to pods in pet set.
func GetStatefulSetPodsEvents(client *client.Clientset, namespace, statefulSetName string) (
	[]api.Event, error) {

	statefulSet, err := client.Apps().StatefulSets(namespace).Get(statefulSetName)

	if err != nil {
		return nil, err
	}

	podEvents, err := event.GetPodsEvents(client, namespace, statefulSet.Spec.Selector.MatchLabels)

	if err != nil {
		return nil, err
	}

	return podEvents, nil
}
예제 #3
0
// Returns array of api pods targeting pet set with given name.
func getRawStatefulSetPods(client *k8sClient.Clientset, statefulSetName, namespace string) (
	[]api.Pod, error) {

	statefulSet, err := client.Apps().StatefulSets(namespace).Get(statefulSetName)
	if err != nil {
		return nil, err
	}

	channels := &common.ResourceChannels{
		PodList: common.GetPodListChannel(client, common.NewSameNamespaceQuery(namespace), 1),
	}

	podList := <-channels.PodList.List
	if err := <-channels.PodList.Error; err != nil {
		return nil, err
	}

	matchingPods := common.FilterNamespacedPodsByLabelSelector(podList.Items,
		statefulSet.ObjectMeta.Namespace, statefulSet.Spec.Selector)
	return matchingPods, nil
}